[Zope3-dev] DISCUSS: Designing for debuggability

Ken Manheimer klm@zope.com
Wed, 12 Dec 2001 11:38:06 -0500 (EST)


On Wed, 12 Dec 2001, Shane Hathaway wrote:

> I perceive a need for a pdb-like capability with a friendly UI and the
> ability to debug higher level languages like DTML and page templates.
> I've often needed to step into code without having to memorize

I agree!

> Paul Everitt wrote:

> > To address your point, a Python prompt combined with ZEO might be the
> > ultimate debugging interface -- provided that you can easily step into
> > and recreate a problem that just happened.
>
> We already have that, don't we?  "import pdb; pdb.set_trace()".

I do this all the time.  In fact, i even do this in "script(python)"
thingies - but there, i have to extrapolate where i am, since the
interpreter apparently doesn't have the source lines available.

(Some notes:

 - I do get line numbers i can use, but they're almost always off by a
   constant that probably depends on the special comment lines at the top
   of the filesystem-based pythonscripts i debug.  Would be nice if that
   bias were corrected.  Would be *way* nicer if the interpreter could
   show the source lines, of course!

 - In order to use pdb.set_trace() in a python script (or, shudder, dtml
   or ZPT, but i almost never go there!), you have to tell security to
   allow it.  To do that, i typically put the following in some product
   module::

    # XXX Enable use of pdb.set_trace() in python scripts, etc:
    AccessControl.ModuleSecurityInfo('pdb').declarePublic('set_trace')

--
Ken
klm@zope.com