If you are using Zope 2.5, then you can use the ram-based temp_folder to store data in memory on the server. Otherwise you can use RAM caching, which is a separate Zope level service . There's bound to be a howto somewhere.... -Casey --- Dieter Maurer <dieter@handshake.de> wrote:
Gregory Popovitch writes:
I am writing a product which loads a large python structure object from disk. I don't wish to store this structure in the Zope Zodb, so I load it in a variable prefixed with _v_.
The code looks like:
class myproduct(SimpleItem.SimpleItem):
def __init__(self, id, title): " initializes a new instance of a myproduct" self.id = id self.title = title self._v_store = None
def load(self): " load store into memory " import mystore if not hasattr(self, '_v_store') or not self._v_store: print "loading store" self._v_store = mystore.LoadStore(self.title)
The function self.load() is called from each URL method to ensure that the store is loaded.
My problem is that after some inactivity in the web server, I can see that the store is reloaded when a web page is requested, and it takes some time.
I assume that the object self._v_store has been flushed from the zodb cache and discarded. Your "self" is flushed from the cache, when it is later reloaded from ZODB, it lost its "_v_store".
I do not know a way how to prevent selective objects from being flushed. But you can globally change flushing behaviour in "Control Panel"->"Database Management"->"Cache Management" (or some similar path).
Dieter
__________________________________________________ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com