Using pdb in Zope page templates

Adam Alton - November 5th, 2009

It occurred to me a while ago that it must be possible to get into PDB in a Zope page template by using the ‘python:’ TALE and the magic ‘modules’ variable that is available there.  And you can!  It’s really dirty, but I’m sure it must be possible to do something useful with it:

<tal:x define=”x python:modules['pdb'].set_trace()” />

When the page is loaded it successfully drops you into the Python Debugger in the terminal, but it seems to be in some kind of context-less, etherial, undefined mystery state in which you can’t access any of the things that you would normally be able to access with python in a tal template.

Can anyone take this a step further and get it to be useful?

One Response to “Using pdb in Zope page templates”

  1. I’m using PDBDebugMode alot which drops you into pdb on exceptions. I guess it ends up in the same place like you where tal or python expressions are evaluated.
    You don’t see very much at this place in the page template engine and it’s even difficult to collect useful information if you step up through the stack (‘u’), but that’s all you can get in a pdb session.

Leave a Reply