[SOLVED] ]Replacing Products.Archetypes.interfaces.IObjectInitializedEvent with lifecycleevents

We're trying to replace Products.Archetypes.interfaces.IObjectInitializedEvent with zope.lifecycleevents.IObjectCreatedEvent in order to sort certain portal types at the time of creation within the parent folder based on effective date (new new items should appear in the folder listing automatically at the top).

However IObjectCreateEvent is already fired before the content object is placed within the parent folder. So it has no acquisition wrapper, no aq_inner attribute. Is there an event and an option to catch the option at a later state during the creation phase?

If you just want to order by effective date, then you could overwrite the folderListing view for specific interfaces: https://github.com/plone/plone.app.dexterity/blob/49211f43f6ef76d11fd83284042d9fc21b1949fb/plone/app/dexterity/browser/folder_listing.py#L51

Do not touch, it is legacy. Archetypes is dead dead dead.

I think that zope.lifecycleevent.interfaces.IObjectAddedEvent is what you are looking for.
IIRC it is also fired when you move an object. If I am right you might want to take care of that.

Misunderstanding: the code is DX only...there is just an add-on that implements this functionality using the mentioned events at the moment.

Possibly a good hint. The event is not mentioned here:

https://docs.plone.org/develop/addons/components/events.html

but here:

https://docs.plone.org/external/plone.app.dexterity/docs/advanced/event-handlers.html

IObjectAddedEvent worked.

1 Like

Plone Foundation Code of Conduct