[Zope-dev] The Product API is not easy to use!

Michel Pelletier michel@digicool.com
Fri, 2 Jul 1999 14:19:15 -0400


> -----Original Message-----
> From: Josh Zeidner [mailto:jmz_phylogenic@hotmail.com]
> Sent: Friday, July 02, 1999 1:32 AM
> To: zope-dev@zope.org
> Subject: [Zope-dev] The Product API is not easy to use!
> 
> 
>   I have been trying to make my own Zope product and I am 
> sorry to say that 
> I have found it to be a daunting task.  Does anyone know 
> where I can go to 
> get better info?  Is there anyone who has created a product 
> who is not 
> working for Digital Creations?  Debugging facilities are 
> non-existent and 
> documentation is esoteric.  Should I say goodbye to Zope forever?
> 

For years the Apache module API was difficult to use and undocumented.
Would you have said goodbye to Apache then?

There are lots of new docs on the horizon.  Amos and Pam are
coordinating the new Zope Developers Guide, and soon there will be a
*very* exciting announcment on Zope developer documentation that will be
available in about six months.

This has been a long standing problem, my first Zope app was when Zope
was Principia and the source code was encrypted bytecode, the only way
to figure out the API then was to bug Jim and use black-boxing
techniques in a python interpreter (and yes, I had to walk uphill both
ways to work every day too).  Now that the source code is available and
you get to know your way around, documentation is almost superfulous
(that's what we tell ourselves at least, we realize that this is an
unacceptable situation for most).

There are two extrememly useful debugging tools, one is even documented.
The Zope debugger and the medusa monitor client.  The debugger lets you
simulate a REQUEST to Zope and to enter the Python debugger at certain
key breakpoints in the request path.

cd to lib/python (make sure Zope is NOT running):

[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
>>> import Zope, ZPublisher
>>> ZPublisher.Zope('')

... output from a request for '' which is the same as
http://machine:port/

>>> ZPublisher.Zope('/manage', u='superuser:123', d=1)

... 'd=1' means enter the debugger immediatly, u='' is the userid and
password to access the request (if it needs one).  More information on
the pyhton debugger can be found at http://www.python.org

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

... runs the requst for '' 1000 times and prints the average time it
takes to complete one request.

Note that the above is for Zope 2.0 ONLY.  If you are using Zope 1.10.2
it works ALMOST the same, except instead of saying 'Zope' everywhere,
you say 'Main' like:

>>> import Main, ZPublisher
>>> ZPublisher.Main('')

The medusa monitor client put you at a python prompt, RIGHT INSIDE ZOPE.
This is so incredibly useful that sometimes I break into Tears Of Joy
(tm) that Sam implimented this.

Go to your top level directory and cd ZServer/medusa:


[michel@aldous medusa]$ python1.5.2 monitor_client.py localhost 9999
Enter Password: XXXXX

Python 1.5.2 (#1, Apr 14 1999, 10:34:26)  [GCC 2.7.2.3]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Welcome to <secure_monitor_channel connected 127.0.0.1:2499 at 85f88c8>
[Hint: try 'from __main__ import *']
>>> import Zope
>>> x = Zope.app()
>>> x
<Application instance at 86dc130>
>>> x.cat
<ZCatalog instance at 86e90a0>
>>> 

You are sitting right inside Zope.  x=Zope.app() makes a connection to
the database, at which point 'x' is the 'root folder' of your Zope
install.

(ZDP guys, you might want to put this on the site)

-Michel


> - Josh Zeidner
>   Phylogenic Inc
> 
> 
> _______________________________________________________________
> Get Free Email and Do More On The Web. Visit http://www.msn.com
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://www.zope.org/mailman/listinfo/zope-dev
> 
> (For non-developer, user-level issues, use the companion list,
> zope@zope.org, http://www.zope.org/mailman/listinfo/zope )
>