[Zope] Testing products outside of zope (i.e., in python inte rpreter)?

Michel Pelletier michel@digicool.com
Fri, 7 Jan 2000 12:11:44 -0500


> -----Original Message-----
> From: Joe Grace [mailto:Occam@Wizards.com]
> Sent: Thursday, January 06, 2000 6:32 PM
> To: zope@zope.org
> Cc: occam@serv.net
> Subject: [Zope] Testing products outside of zope (i.e., in python
> interpreter)?
> 
> 
> Hi,
> 
> is there a way to test zope products outside of zope?  

If your code is not Zope depenent, you can.  If your code it, you can
use the Zope debugger (based on the Python debugger) but at that point
you are not 'outside of Zope', you are just not accessing it through the
web, but via a debugger prompt.

> I find that I'm
> restarting zope just to update my product and test it, and that seems
> painfully slow.  I'd like to just run code outside of zope 
> interactively
> in a shell.  Is that possible?

Yes.

> I'm trying with Boring product (super
> simple) and tripping over the Persistence import
> 
> 	Import Error: cannot import name Persistent
> 
> I've run into this problem before and assume that Persistent is a C
> function. 

It is an ExtensionClass written in C, yes.  To get around this you need
to 'import Zope'.

> How do I make it available to my python interpreter?  I
> couldn't figure out where z2.py gets it, but I also am just 
> dealing with
> the python environment for the first time.  I'm using Xemacs 
> (on NT) if
> that makes giving some tips any easier. :-)

Yep.  Open a shell buffer in your lib/python directory.  In my Zope, I
have an object in the top level folder called 'Catalog', which is a
ZCatalog object.

[michel@korak python]$ python1.5.2
Python 1.5.2 (#1, Jul  5 1999, 14:47:37)  [GCC egcs-2.91.66
19990314/Linux (egcs- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Py$ import Zope, ZPublisher
Py$ root_folder = Zope.app()
Py$ root_folder.Catalog
<ZCatalog instance at 84f77c0>
Py$ root_folder.Catalog()
[]
Py$ 

-Michel