Zope and Persistence

Terry Hancock hancock at anansispaceworks.com
Sat Oct 22 20:47:01 CEST 2005

On Saturday 22 October 2005 12:34 pm, ryankaskel at gmail.com wrote:
> I don't know if this is the appropriate place to post a Zope question
> but I figure many here are familiar with it.

You will do much better to use the Zope users' mailing list. Go to
zope.org and follow the mailing lists link to sign up.

> I'm confused about the
> role of the ZMI when it comes to development. I want to write a simple
> script that logs page hits. I wrote it in what was called a Script
> (Python) resource in the ZMI. When I access the page it gives an error
> saying that this file cannot import Persistence, etc.

Python scripts are NOT Python modules, and you should not have to
import anything to make use of persistence. Objects you manipulate
using the ZMI interface are pretty much always objects in the ZODB
database (anything that shows up as an "object" or a "property" in
the ZMI is a persistent object).

What you want to do is add an integer "property" to the folder containing
the script (i.e. "context" or "container", depending on whether you want
to maintain a count in the directory from which the script is called,
or one unique counter where the script is stored).  That's your counter.

Also, be sure to follow the "help" link in the ZMI and use the online
API documentation.

> This makes sense
> but where would I put this script and how would I invoke it? It is only
> supposed to store an integer in Data.fs. Thanks.

If you actually needed imports and access to the internal ZODB machinery,
then you would need to write a "Product", not work in the ZMI at all.

But you don't.


Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

More information about the Python-list mailing list