Hi
I am trying to intercept the "copy" event for a specific type, so that I can
generate a customized id for the copied object.
In my old Plone 2.5.2 system I have always overridden generatUniqueId, where
I generate a custom id for this type when it
is created, in the format 'XYZ.CE001'.
Now, in Plone 3, I also want to generate the same custom id when an object
is copied, so I use generateUniqueId again in my handler.
(Both the id and title of the object is set to the same custom generated id)
I have the following subscriber in my configure.zcml:
<subscriber
for="Products.ProjectManager.interfaces.ICostEstimate
zope.lifecycleevent.interfaces.IObjectCopiedEvent"
handler=".events.handleCostEstimateCopied"
/>
Then I have the following handler:
def handleCostEstimateCopied(self, event):
"""
"""
assert self.portal_type == 'CostEstimate'
# intercept copy event and generate the correct id and title for
# the copied object
import transaction
transaction.commit()
ce_id = event.original.generateUniqueId('CostEstimate')
event.object.setId(ce_id)
event.object.setTitle(ce_id)
event.object.reindexObject()
Everything works fine, except for setId.
The title is set correctly, but the id remains, for example
'copy_of_XYZ.CE007', whereas it should be 'XYZ.CE008'.
Which method must I use instead of setId() or edit(id=newid), since these do
not change the id.
Thanks!
Arno Blumer
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers