[Zope-dev] Persistence of objects created by external methods

Jason Abate jason@hostway.net
Wed, 15 Dec 1999 10:23:59 -0600


I have a fairly sizable application built on top of Zope that is based on a
bunch of my own Python code.  This was started about 9 months ago, so it
probably doesn't use the latest Zope-isms, but it works for the most part,
except that I now have a problem with persistence.  Here's the setup I have:

I have a Python class called SiteControl, and an external method, taken from
some early Zope documentation, which creates an instance of this class and
stores it in the Zope database:

  from Shared.SiteControl.SiteControl import SiteControl

  def CreateSiteControl(self):
    "Add a SiteControl instance"
    setattr(self, 'SiteControl', SiteControl())
    return "Created SiteControl instance"

This works fine - I can access the SiteControl object and all of its methods
from a browser.  The problem is that the SiteControl object contains two
dictionaries which store a list of users currently logged into the system.
In the __init__() method, these are initialized to be empty dictionaries.
What I would like is for these dictionaries to be persistent.  However,
whenever the server is restarted (which seems to happen fairly frequently.
I'm still tracking this down, and guess that it is a problem with my code
rather than Zope), the dictionaries are reset to be empty, which requires
users to login again.

Is it possible to have these objects that are in the SiteControl object
persistently stored in the Zope database?  I've tried to subclass
SiteControl from Persistent, but it seems to be just a document string and
no class.  Am I missing something here?  Is there some other way to make
these subobjects persistent?

Thanks for any help,

--jason

--
Jason Abate
Hostway Corporation
jason@hostway.com