By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,035 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,035 IT Pros & Developers. It's quick & easy.

Zope and Persistence

P: n/a
I don't know if this is the appropriate place to post a Zope question
but I figure many here are familiar with it. 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. 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.

Oct 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Saturday 22 October 2005 12:34 pm, ry********@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.

Cheers,
Terry

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

Oct 22 '05 #2

P: n/a
ry********@gmail.com wrote:
I don't know if this is the appropriate place to post a Zope question
Nope. You'd better use the zope mailing-list for this.

<OT> but I figure many here are familiar with it. I'm confused about the
role of the ZMI when it comes to development.
As it's name implies, the ZMI is a *management* interface. Real Zope
developpement is better made with filesystem "Products" (Zope components).
I want to write a simple
script that logs page hits.
That's a typical case of reinventig the square wheel. Ever looked at
<you-zope-instance-folder-here>/log/Z2.log ? It's an apache-like access
log. And there are a whole lot of tools for building stats from apache
access logs.

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.
Why would you import Persistence in a Python Script ? This is already a
persistent object.
This makes sense
but where would I put this script
Whereever seems to fit - this depends on your application.
and how would I invoke it?
Like any other Zope object.
It is only
supposed to store an integer in Data.fs. Thanks.


This is another problem, and I think you'd better start with the zope book.

But for you current use case, first have a look at Zope's access log.
</OT>

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Oct 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.