[Zope] One time persistent variable
Jim Washington
jwashin@vt.edu
Thu, 05 Dec 2002 07:59:09 -0500
Antonio Beamud Montero wrote:
>Hi all:
>How I can make a variable from a Product persistent, but only exists a
>copy in the ZODB?, i.e. this variable is updated every 30 sec. and I
>don't want ZODB saves all old states of this variable, only the last...
>How I can make this...?
>
>Thanks in advance
>
>
You do not specify whether it is a file-system Product or ZODB Product.
My preference would be to go simpler, rather than installing a
non-replicating storage for something small like this. That is,
however, an option (search for non-replicating storage).
If it is a filesystem product, you have the option of writing the data
to a file. I would look at the FSCounter Product for an example of how
this would be done.
If it is a ZODB product, use gadfly (you already have this!) or another
SQL database if you are using one. Create a database and table and
Z[your Db] Adapter, if necessary, then 'get' and 'set' ZSQL Methods.
If it is a complicated variable, like a class instance, you might want
to investigate the python "pickle" function. This normally will only be
available to a filesystem product or External Method.
You have many options.
-- Jim Washington