[Zope] Re: [Zope-dev] Zope Debugging Tips Solicited

Hung Jung Lu hungjunglu@hotmail.com
Wed, 23 Feb 2000 19:08:42 PST


"james w. howe" <jw-@allencreek.com> wrote:
>I can do with it.  Any debugging tips that anyone might have would be 
>appreciated.

The Python/Zope combination does not seem to have any
nice GUI for debugging... nothing like Visual C++ or
Visual Cafe.

But then, I have also worked with a few languages where
I had only access to simple print statements... At first
this might seem to be primitive, but one thing saves
the day: in these languages you can modify most program
files while the main application is running, like the case
of Zope. (Long-running processes.)

What I do nowadays for Zope is this:

(1) In the standard_footer_html method (or equivalent),
I print out whatever variable I want to print out.
This includes a string that I store in the REQUEST
variable, which you may call debug_output. Typically
I print out three things: (a) REQUEST.debug_output,
(b) the SESSION variables, (c) the REQUEST variable.

(2) I have a flag in the root folder, and setting
or unsetting this flag enables or disables the
print out. So, when I move the development copy
to the production copy, I simply have to unset
the flag to suppress the debug printing.

(3) I implement an external method called dprint(),
and put it in the root folder. This method prints
into the REQUEST.debug_output string. I can print
from any dtml method/document, something like:

  <dtml-call "dprint('Hallo I am here')">
  <dtml-call "dprint(REQUEST.myvar)">

You of course can also call the dprint() method
from within external methods... or maybe you can
implement it as a real Python module and put
it inside your /lib/python/shared/... folder
so you can import it from an external method
file.

---------------------------

The above method is good only if the program does
not have crashes (Zope exceptions.) For nastier
crashes, I physically go into the Python code and
put print statements, so it prints to the console.
Primitive, yes, but so far I have always been able
to catch the bugs I wanted to catch, including a few
from Zope itself and Sybase database adapter.

---------------------------

Of course, if there were some product that
implements a real debug para-server (serving on
a TCP/IP port, so it's platform independent)
with nice HTML GUI interface to poll (or even change)
variable values via a web, and even stepping through
the code, now, that'll be a wonderful product. :)

Hung Jung

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com