You should add a link to the script in question, or at least name it so it can be found.
Also, currently you (and maybe perhaps @evn) are the only one who knows what stands in this first line of this unknown script.
This is the old story, please always think about the fact that we can not read minds, do not stand beside you and that our magic crystal ball is currently at service, and we do not expect it back from service before the end of this millennium …
The reason why pobj is None is because there is no widget with the name “view_0” in the object tree. This happens because “view_0” was already closed. The first document opened on application startup is “view_0”. When the document is closed, “view_0” no longer exists. The second document will have “view_1” and the third document will have “view_2” and so on.
The script was a proof of concept. This code should be more robust.