Maybe you know this one already but I didn't.
Did you know that you can fire up Python and import Zope's Main module to get access to Zope's objects from the comfort of the Python prompt?
1. cd to lib/python, this will make things easier, since you won't have to add lib/python to your sys.path. 2. start Python (if you're using a binary of Zope, you may want to use Zope's copy of Python) 3. import Main 4. The Zope app object is Main.app 5. From there you can get at any Zope object. 6. Some objects may be ghosts and will look empty when you do a dir on them. To load them from the object database, try to access one of their attributes. 7. If you want to make changes to the database don't forget to call get_transaction().commit() to commit your changes.
If you really want to mess up your Zope install this will let you do it in style ;-) Of course you wouldn't be considering this unless your broken Product already messed things up, so what do you have to lose?
Also, don't forget about the Zope debugger which is a more controlled way to get access to Zope internals.
Have fun!
-Amos
Another debugging tip that some of the newer people might not be aware of is Mr. Creosote by Jeff Bauer.
Mr. Creosote is a simple way to basically add print-like statements to your DTML, External Methods or Products. Great for debugging.
For more info, see:
http://starship.python.net/crew/jbauer/creosote/index.html
BTW, thanks Jeff, I love this little tool. :)
---
John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
John Eikenberry wrote:
Another debugging tip that some of the newer people might not be aware of is Mr. Creosote by Jeff Bauer.
Mr. Creosote is a simple way to basically add print-like statements to your DTML, External Methods or Products. Great for debugging.
For more info, see:
http://starship.python.net/crew/jbauer/creosote/index.html
BTW, thanks Jeff, I love this little tool. :)
John,
Thanks for the kind words. I need to document MrCreosote better, particularly for Zope use.
Usually, I place a single line in the debug code, which is simple to [un]comment.
from creosote import MrCreosote; spew=MrCreosote().spew
Subsequent code use just simple spew() statements:
spew("Hello, world")
BTW, The 'C' version of MrCreosote is also being used in some Python CE development and even a Python Netscape/IE Plugin I'm working on.
Best regards,
Jeff Bauer Rubicon, Inc.