[Zope] Persistence Problem

Charlie Reiman creiman@kefta.com
Thu, 15 Aug 2002 17:55:38 -0700


I've got a product that has a little pool of database connections. These are
low level DCOracle2 objects, not Zope DB connections. These live in a hash
table-like cache living in a volatile attribute of a persistent product.

Something like this:

myproduct
  _v_mycache
    conn1
    conn2
    conn3

The cache periodically reaps old connections. The product insures the cache
exists before it uses it, as it is volatile and might not exist at any point
in time. Here's my problem:

Occasionally, my _v_mycahce is empty when I didn't clear it. It looks like
my product object gets dropped from memory, then reloaded, resulting in a
missing cache. If this is true then what I need is an class or attribute
that is persistent for the server lifetime. It looks like all I can get from
Zope is permanent persistent objects or volatile objects.

So my questions are:

1) Can I put a trap somewhere on my object so I know when it gets purged or
loaded? Just a simple "sys.stderr.write('loading\n')" would be enough to
confirm my suspicions.

2) Is there a server-lifetime class of objects? Is there a workaround to get
there? Can I force my object and its attributes to live in memory and not
get purged until shutdown?

Thanks in advance. I think I can work around this with traditional coding
kung-fu, but it'll be a pain. A solution like 'set this attribute to true'
or 'subclass from twiddle' would make me really happy.

Charlie.