[Product-Developers] Re: Intercepting the copy event to generate a custom id

Maurits van Rees m.van.rees at zestsoftware.nl
Fri Jun 6 13:34:29 UTC 2008


Arno Blumer, on 2008-06-06:
> Eventually I used the ObjectAdded event and tested to see whether a copy has
> been made:

Ah, of course, I just remembered something.  You were first
subscribing to the zope.lifecycleevent.interfaces.IObjectCopiedEvent.
The only thing that this event signals is that an object has been
copied into memory.  The new object (that you were setting the id of)
was not yet placed in any folder.  So at that point setId probably
worked, but at the moment it was actually placed in its new location
the generateUniqueId or perhaps processForm was again called, negating
your attempts to set the id.

So IObjectAddedEvent is indeed the correct event to listen to.

BTW, note that the IObjectCopiedEvent actually gets fired not during
copying but during pasting (but you probably saw that already).

-- 
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]





More information about the Product-Developers mailing list