[Zope-CMF] Zope2.12.3 zexp import error

Jens Vagelpohl jens at dataflake.org
Tue Feb 9 16:38:48 EST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/9/10 22:23 , Charlie Clark wrote:
> Am 09.02.2010, 13:46 Uhr, schrieb Jens Vagelpohl <jens at dataflake.org>:
> 
>> Your event handler "handle_new_masterpage" should be rewritten to look
>> if the object it wants to instantiate already exists. If it exists it
>> should obviously not try to instantiate it again.
> 
> Hiya Jens,
> 
> the handlers were written to use IObjectAddedEvent as some things in the  
> Zope2 world can't happen until an object has somewhere to be or more  
> pertinently this is the most common pattern. Adding the check is easy  
> enough but I'm interested in the general pattern here: should we be  
> looking at working with (and notifying) ObjectCreatedEvents? Or should  
> this check become standard?

Hi Charlie,

Checking to see if an object you are trying to instantiate already
exists is simply common sense.

Everyone who writes handlers for IObjectAdded must remember that the
event is not just called when a brand new instance is created, but also
when an existing instance is cut/copied and pasted, and when the Zope
import machinery is used. In those cases a clash is virtually guaranteed
if your event handler tries to blindly add another persistent object
that is already part of the copied or imported instance.

jens

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAktx1egACgkQRAx5nvEhZLKLPACeJV7Sgpd3mAqeotEUQYZbHQfs
7UkAn37q0VpUgQlFgt0jAMN29BOJO6/r
=/Y9l
-----END PGP SIGNATURE-----


More information about the Zope-CMF mailing list