To actually change the obj position in your parent, you can use Zope2 OFS.IOrderedContainer-interface to access the appropriate methods and connect it to zope.lifecycleevent.interfaces.IObjectAddedEvent, as in this Plone-addon " adi.revertorder " (disclaimer: author = meh):
In the list, configure.zcmlregister an eventlistener:
<subscriber for="Products.CMFCore.interfaces.IContentish
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".subscriber.revertOrder" />
And in the handler (here:) subscriber.pydefine the called method:
from Acquisition import aq_inner
from Acquisition import aq_parent
from OFS.interfaces import IOrderedContainer
def revertOrder(obj, eve):
"""
Use IOrderedContainer interface to move an object to top of folder on creation.
"""
parent = obj.aq_inner.aq_parent
ordered = IOrderedContainer(parent, None)
if ordered is not None:
ordered.moveObjectToPosition(obj.getId(), 0)
Refers to a content type based on Dexterity and Archetype.
See also docs: http://docs.plone.org/external/plone.app.dexterity/docs/advanced/event-handlers.html
source
share