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

Arno Blumer arnoblumer at gmail.com
Fri Jun 6 14:12:50 UTC 2008


Yes, I'm going to use that event now.
However, is there a better way of testing whether an object has been copied,
or whether there
is something on the clipboard?
At the moment I use:
if event.newName.startswith('copy'),
and this is of course only the case when the object is copied to somewhere
in the same folder.
I thought of testing with event.oldParent, but this always seems to be None,
whether the object is copied or newly created.

On Fri, Jun 6, 2008 at 3:34 PM, Maurits van Rees <m.van.rees at zestsoftware.nl>
wrote:

> 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]
>
>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20080606/088ac116/attachment-0001.html>


More information about the Product-Developers mailing list