How to test/debug a Product in stand alone?
Went through the tutorial where a poll product was created, and I thought I understood it. But no.... Applying "monkey see, monkey do" to my own python stuff to transform it into a product, I somehow introduced bugs into previously working code. What do I run to debug a product module? There is a gap in the tutorial between explaining how we can check our original python code but little about debugging a product. Running ZPublisher/test on the product no longer works because the test routine says that it couldn't import Persistent. I tried ZPublisher/test the poll product and got the same error message. Obviously when Zope pulls itself up it is changing its search path somehow. I added sys.path.insert(0,'myzopepath/lib/python/ZODB') and some of the error messages went away but not the 'cannot import name Persistent' was rather stubborn and refuses to go away. Has anyone sorted this one out before?
Chui Tey wrote:
What do I run to debug a product module? There is a gap in the tutorial between explaining how we can check our original python code but little about debugging a product.
I have just started putting together a How-To related to this. If anyone has insight into product debugging or has something to contribute please set it my way. The existing Debugging how-to describes some things but it took a little imagination to jump from Monkey-See to Monkey-Debug.
Running ZPublisher/test on the product no longer works because the test routine says that it couldn't import Persistent. I tried ZPublisher/test the poll product and got the same error message. Obviously when Zope pulls itself up it is changing its search path somehow. I added sys.path.insert(0,'myzopepath/lib/python/ZODB') and some of the error messages went away but not the 'cannot import name Persistent' was rather stubborn and refuses to go away. Has anyone sorted this one out before?
Please... correct me if I am wrong! Test.py that comes with the ZPublisher package was a generic bobo test script in that publishes resources within modules. We may wish to publish the a resource /spam/eggs within Zope, so you pass "Zope" as the module and /spam/eggs as PATH_INFO: python Test.py Zope "/spam/eggs" -u "superuser:123" or from the interpreter:
import ZPublisher ZPublisher.Zope("/spam/eggs", u="superuser:123")
If you have an empty ZODB then you can add items from the interpreter (untested and probably unfounded ;)
import Zope root = Zope.app() root._setOb('PollSample', Poll("Question", ["Answer1", "Answer2"])) print root.PollSample root.getTransaction().commit()
There is one gotcha described in http://www.zope.org:8080/Documentation/Reference/Debugger where the environment variable INSTANCE_HOME may need to be set to the zope directory (/usr/local/zope in my case), I don't know if this has been fixed. Newbie warning.... Could someone please describe why Zope is the module name and not the product one is developing? -Sean
participants (2)
-
Chui.Tey@env.qld.gov.au -
Sean Treadway