[Zope] Object reload event?
Dylan Jay
me at dylanjay.com
Wed Mar 10 17:29:19 EST 2004
----- Original Message -----
From: "Dieter Maurer" <dieter at handshake.de>
To: "Dylan Jay" <me at dylanjay.com>
Cc: <zope at zope.org>
Sent: Thursday, March 11, 2004 7:48 AM
Subject: Re: [Zope] Object reload event?
> Dylan Jay wrote at 2004-3-9 16:37 +1100:
> >I have an object that uses manage_afterAdd to install several subobjects.
> >When this object is refreshed or zope is started I want to have a method
run
> >on each instance of that object to ensure these subobjects are still
there
> >and are of the right type. How do I do this?
>
> Whenever an object is loaded from ZODB, its "__setstate__" method
> is called.
>
> However, you are severely restricted what you can do in this
> method:
>
> * "self" is not acquisition wrapped.
>
> This means, you cannot access the position of the object
> inside the Zope object hierarchy.
>
> * Modification you make to the object may not become persistent.
Not really suitable then.
>
> It is probably better to design a consistency checking script
> that periodically checks your consistency requirements.
>
> Even better would be to prevent your system to become
> inconsistent (rather than detect inconsistency at a later time).
It's not so much inconsistency of data that I'm trying to fix but rather to
make it easier for me to upgrade my more complex objects. I havc a product
with an object that has a subobject such as a predefined catalog. When a I
am developing I want to able to check if there is anything new to add to
that catalog such as a new index. So I guess being able to hook into the
refresh functionality would be enough.
> --
> Dieter
>
More information about the Zope
mailing list