python

start zope with foreground debug messages

SOFTWARE: python

zopectl fg

Debug zope crashes

Change directory to your zope instance's bin directory. For example on my setup this is:

cd /var/opt/zope/default/bin

Now fire up zope server with the fg (foreground) flag:

./zopectl fg

This will fire up the zope server and also spit out messages to your terminal window telling you what's going on. Critical for debugging failures on start up.

eggs cache directory failure

I had a problem with the cache directory for eggs not being writeable by zope. Fixed with this:

fix eggs dir problem

MORE INFO: http://plone.org/products/documentation/error/permission-denied-python-eggs

tab NOT same as four spaces

SOFTWARE: python

textmate > view > invisibles

Python Indentation

Python is sensitive to whitespace. Tabs are not the same as four spaces. Don't mix the two in your code or you'll get bugs. If you get this error:

IndentationError: unindent does not match any outer indentation level

then you know you've got something indented incorrectly in your code. I found that viewing invisibles in textmate (or whatever text editor you're using) is very helpful.

textmate > view > invisibles

or

OPT CMD I (key combo)
MORE INFO: http://en.wikipedia.org/wiki/Python_syntax_and_semantics

php print_r equivalent in python

SOFTWARE: python

repr()

To get at the structure and contents of an array in python you can use:

repr()

For example, if you have an array "crumb" which stores information about URL and Title for a given page:

repr(crumb)

Might give you something like:

{'absolute_url': 'http://mydomain.com/stuff', 'Title': 'Page Title'}

So this is kind of like print_r in php.

MORE INFO: http://docs.python.org/tut/node9.html
Comments