Le 28 juil. 2011 à 16:15, imran.azad a écrit :
> Hi,
>
> How can I workout if an object has been 'modified' or whether it's a new
> object within the IObjectModifiedEvent event? The issue is that
> IObjectModifiedEvent is trigged even if an object is added. I need the code
> below to execute only when an object is 'modified:
You could mark the creation in the request. I know this seems somehow overkill
but, assuming the IObjectCreatedEvent comes first...
@grok.subscribe(IPerson, IObjectCreatedEvent)
def markCreationOnly(person, event):
# Other stuffs ?
request = person.REQUEST
request.set('__created_person__', person.getPhysicalPath())
>
> @grok.subscribe(IPerson, IObjectModifiedEvent)
>
> def rename(person, event):
request = person.REQUEST
created = request.get('__created_person__', False)
if created and person.getPhysicalPath() == created:
# Object created and modified
return
> id = person.getId()
> parent = person.aq_parent
> parent.manage_renameObject(id, baseNormalize(person.title))
>
> Thanks
>
> --
> View this message in context:
> http://plone.293351.n2.nabble.com/IObjectModifiedEvent-object-modified-or-added-tp6630019p6630019.html
> Sent from the Product Developers mailing list archive at Nabble.com.
> _______________________________________________
> Product-Developers mailing list
> [email protected]
> https://lists.plone.org/mailman/listinfo/plone-product-developers
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers