Re: [Zope-dev] Zope/Python Object Persistence
"Adam Pawliuk" <apawliuk@aui.ca> wrote:
This is a multi-part message in MIME format.
First, please *don't* post MIME/HTML to the list. If you need to reference a file too long to quote inline, upload it someplace (e.g., join www.zope.org and put it in your member folder there) and post the URL.
Is there a way that I can maintain persistent python objects in memory = through the Zope Server?
As a simple example if I create a counter in a python module and access = it through an external method, the module seems to get reloaded every so = often, so the counter will get reset. Can I avoid this? Basically I just = want to keep a persistent hashtable/Dictionary.
MODULE: ************************************************************* __persist =3D {}; __persist['count'] =3D 0;
def getNextCount(): __persist['count'] =3D int( __persist['count'] )+1 return __persist['count'] ************************************************************ External method in DTML:
<dtml-var "getNextCount()">
thanks in advance
You _don't_ want to store such a volatile object in the ZODB -- the tradeoffs of its transaction/undo machinery are almost completely opposed to such usage. What you need is to persist the value to the filesystem (using FSSession or a workalike) or to a relational backend (using SQLSession). On the whole, I would recommend checking out FSSession on the products page: http://www.zope.org/Products Tres. -- ========================================================= Tres Seaver tseaver@digicool.com tseaver@palladion.com
participants (1)
-
Tres Seaver