[Zope] Volatile variables Problem
Casey Duncan
casey@zope.com
Wed, 5 Feb 2003 09:50:08 -0500
On Wednesday 05 February 2003 09:15 am, Oliver Bleutgen wrote:
> Antonio Beamud Montero wrote:
> > Hi all:
> > Well, i have a serious problem... I have defined a variable inside my
> > product that I refresh periodically via XML-RPC (every ~1 min). I nee=
d
> > to maintain this variable volatile because ZODB grows to the infinite=
=2E..
> > The problem arises when a new conection is established an the variabl=
e
> > value need to be shown. In some cases the query raises an
> > AttributeException. Now I catch this exception, but this no solves my
> > problem...=20
> > Why the value of this variable is lost?
>=20
>=20
> Since nobody responded till now, here are my 5c.
> Volatile attributes are only guaranted to exist as long a transaction=20
> AFAIK, OTOH they are also not guaranted to _not_ exist longer, which=20
> might explain that you don't see this failure everytime.
Volatiles (_v_ variables) are thread-specific. A request handled by one t=
hread=20
won't see volatiles created on another thread.
=20
> So, I fear volatile attributes can't help you here.
>=20
> > How I can solve the problem?
>=20
> Hmm, an external method which stores the values in a file? A external=20
> database? The sessioning stuff?
>=20
> Sorry, I have no really good idea there, maybe it helps if you explain=20
> what you want to do in more detail ...
You can use sessions, but they are user-specific. If it needs to be globa=
l to=20
all users, create a persistent class and store an instance in the temp_fo=
lder=20
(which is where the seesion data is stored). That is a volatile storage=20
shared between all threads. It will only be lost if Zope restarts.
hth,
-Casey