Archaeopteryx Software, Inc.
Take Flight!Search

Wing IDE
About Us
Open Source

 Advanced Search

[wingide-users] Debugging ZPTs with Wing

Wing IDE Support support at
Wed, 22 Jan 2003 22:10:06 -0500 (EST)

On Wed, 22 Jan 2003, Kevin Teague wrote:
> I suppose it would be quite difficult (probably really, really
> difficult?), but if Wing also debugged Python Scripts and Zope Page
> Templates (ZPT) that lived on the filesystem, that would be really
> cool. Setting a break point in ZPT would be kind of nifty :)

Actually, John and I talked in the past with Jim Fulton about making DTML
frames look like Python stack frames, so that they could be debugged with
a Python debugger.  Perhaps ZPT is closer to allowing this as a result of
those conversations (just a wild guess/hope; I'm not up on this part of
the Zope internals).

We don't have the resources to do this ourselves any time soon but would
give anyone that succeeds at it access to free lifetime product from
Archaeopteryx (unlimited 1-user licenses to anything).

Despite that proprietary carrot, it should be done as a general
improvement to Zope and not as something Wing-specific.

Basically what is needed is:

* Create Python functions on the fly out of page template code.
  These should be named so the template name is clear to user.
* Set up the template processing code so it's not a table driven
  or parser-based implementation but driven by these generated
  functions calling each other with appropriate locals/globals
* Write the templates to disk temporarily if they aren't already
* Modify the Python code objects on the fly to alter the file
  name in them to point to the template file
* Modify the Python byte code for the code objects on the fly
  to set the line numbers to match the lines in the template file.
* Add some sort of ZMI switch to turn on and off the above scheme,
  which is likely slower than normal processing of templates.
* Possibly, add some cooking of exceptions so they make more
  sense to the user.

I'm sure there are fine points to be worked through, and I don't know how
easy or Python version dependent the byte code munging will be.  But this
should pretty much fake any Python debugger into stepping through the page
template, showing reasonable locals/globals, allowing breakpoints to work,
showing exceptions, etc.

Of course we'ld be happy to give further pointers to anyone that wants
to attempt this.

- Stephan

Run by Mailman v 2.0.8

Copyright (c) 2000-2002, Archaeopteryx Software, Inc.
Legal Statements