On Thu, 29 Jun 2000, Steve Alexander wrote:

> Hi folks,
> Is there any way of interacting with the ZODB persistence machinery to
> add the default attribute to all instances as they are brought out of
> persistent storage -- so that I can just restart Zope, and have all of
> my instances updated as I use them ?

In addition to the method Bryan detailed, you should look into the
__setstate__() method.

>From http://www.zope.org/Members/michel/HowTos/ZODB-How-To:

  "When an object is activated by the object database and brought into
   memory, it's __setstate__() method is called. A Persistent class can
   override this method to initialize the object every time it is brought
   into memory.

   __setstate__() is also useful to upgrade an object from one version to
   another. If you add instance attributes to your product, older versions
   of the instances of that product will not have the new attribute.
   __setstate__ can check for the existance of new attributes, and create
   them with sane defaults in older versions of the instance."

> Thanks for any help.

Hope this helps.


Jeff K. Hoffman                               704.849.0731 x108
Chief Technology Officer                      mailto:[EMAIL PROTECTED]
Going Virtual, L.L.C.                         http://www.goingv.com/

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to