[Zope] Python -> ZopePython cheat sheet?

Chris McDonough chrism@zope.com
05 Nov 2002 12:12:41 -0500


On Tue, 2002-11-05 at 11:55, Skip Montanaro wrote:
> The version of Python 2.1 which ships with the Plone MacOSX installer
> doesn't have a readline module with it, and doesn't seem to have shipped
> with complete sources, so it seemed like six of one half a dozeon of the
> other to me.  I've just built a readline.so using a source version of 2.1.3.

Ah ok.

> That seems to work.  I don't understand how your scheme works to talk to a
> running Zope instance though.  I don't have ZEO and by the time I can figure
> out how to install and use it, I suspect I will have fumbled around enough
> with the monitor client to figure out what I need.

The monitor client is pretty crippled (I suspect you'll see this once
you start really using it) because of its traceback output and whatnot
(truncated tracebacks, from what I remember).  To avoid this, I
recommend "importing Zope" in an interactive Python session instead. 
"cd lib/python; python; import Zope; app = Zope.app()".  The only
problem with this is that Zope cannot be running at the time you do this
unless you're running ZEO.

If you really want to inspect a running Zope, I have to recommend
spending the time to install ZEO.  It's really very easy to install if
you follow the instructions in the tarball within
http://www.zope.org/Products/ZEO/ZEO-2.0.tar.gz/view .

>     >> Is there some way I can make dir() and type() available to scripts
>     >> for development purposes and make sys importable once again?
> 
>     Chris> Not without hacking source, 
> 
> That seems a helluva a lot easier than some of the other hoops I'm having to
> jump through.

Hope it works out.

> >From where I sit it seems Zope needs some serious work on its debugging
> capabilities.  At a minimum, giving people the option of starting up Zope
> with a flag that returns control of their Python interpreter to them would
> be a good first step.

This is the "cd lib/python; python; import Zope; app = Zope.app()" trick
that I mention above and I've sent in other emails.

Upcoming versions of Zope will likely ship with a utility to make this
less obscure by providing a frontend controller application to Zope
named "zctl" that you can run to do this by doing "./zctl debug".  This
feature is currently in-place in a branch of Zope I'm doing work on
(chrism-install-branch).

- C