[Zope-dev] Zope/Python Object Persistence

Adam Pawliuk apawliuk@aui.ca
Mon, 1 May 2000 17:52:36 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_0014_01BFB396.09266240
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

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


------=_NextPart_000_0014_01BFB396.09266240
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Is there a way that I can maintain =
persistent=20
python objects in memory&nbsp;through the Zope Server?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>As a simple example if I create a =
counter in a=20
python module and access it through an external method, the module seems =
to get=20
reloaded every so often, so the counter will get reset. Can I avoid =
this?=20
Basically I just want to keep a persistent =
hashtable/Dictionary.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>MODULE:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>*************************************************************</F=
ONT></DIV>
<DIV><FONT face=3DArial size=3D2>__persist =3D {};<BR>__persist['count'] =
=3D=20
0;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def getNextCount():<BR>&nbsp;&nbsp;=20
__persist['count'] =3D int( __persist['count'] )+1<BR>&nbsp;&nbsp; =
return=20
__persist['count']</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>************************************************************</FO=
NT></DIV>
<DIV><FONT face=3DArial size=3D2>External method&nbsp;in =
DTML:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-var =
"getNextCount()"&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks in advance</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0014_01BFB396.09266240--