[Zope] Python Products

Michel Pelletier michel@digicool.com
Tue, 21 Dec 1999 16:16:29 -0500


> -----Original Message-----
> From: Sam Gendler [mailto:sgendler@impossible.com]
> Sent: Tuesday, December 21, 1999 3:04 PM
> To: Stephen Pitts
> Cc: zope@zope.org
> Subject: Re: [Zope] Python Products
> 
> 
> Stephen Pitts wrote:
> 
> > Is there any way to get Zope to reread a Python product's 
> files without
> > restarting? I'm developing using a cycle like this:
> > * change .py file in lib/python/Products/*
> > * save changes
> > * restart Zope (takes 10 seconds :-()

Also, forgoing the overhead of firing up Zope and accesing it with HTTP
makes debugging and hardcore python level development much easier.  You
can do this by running Zope directly in a python interpreter by using
the Zope 'debugger'.

(This is the last time I do this demonstration, someone better write a
how-to!)

[michel@aldous python]$ python1.5.2
Python 1.5.2 (#1, Apr 14 1999, 10:34:26)  [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam

(You are now in python)

>>> import ZPublisher, Zope

(This 'runs' Zope)

>>> ZPublisher.Zope('')

(This fetches the index_html method in the root folder. Identical to
accessing just the root level folder of your Zope *through the web*)

<html>......</html>

>>> ZPublisher.Zope('', d=1)

(This puts you in the debugger)

* Type "s<cr>c<cr>" to jump to beginning of real publishing process.
* Then type c<cr> to jump to the beginning of the URL traversal
  algorithm.
* Then type c<cr> to jump to published object call.
> <string>(0)?()
pdb> 

(Just like it says, you can step into the debugger and continue to the
first pre-set breakpoint, which is right before the publisher kicks in.
The second breakpoint is before the URL is traversed, and the third (and
most useful to product developers) breakpoint is right before the
discovered object is called)

The Zen of Zope debugging is pretty deep, but actualy very easy to grasp
IF you know how to use the python debugger BEFOREHAND.  90% of the
complexity of debugging Zope is knowing how to use a command line
debugger like python's (anyone familar with gdb should feel at home).

-Michel