Post-creation actions on Dexterity content

I have a folderish content-type that accepts other 'Folder' objects as subjects. I need to attach folder restrictions to newly created Folders . In side a handler for IObjectCreatedEvent I can get hold of the related folder instance however the folder instance is not acquisition-wrapped or not finally constructed in order get hold of the parent for performing some further checks. Is there a different way hooking into the Dexterity content-type creation cycle?

-aj

How about def _setObject in the container class?

Dexterity's addContentToContainer (and createContentInContainer) call container._setObject

-Roel

Or, use IObjectAddedEvent which should have event.newParent

Then obj should be aq wrapped, or you can do it yourself with _of_:

def handle(obj, event):
    aq_wrapped = obj.__of__(event.newParent)

IObjectAddedEvent could work.

There is duplicate and inconsistent and incomplete documentation on events here.

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

More complete:

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

In corner cases where I have been unable to use IObjectAddedEvent, IIRC, I have resorted in IObjectCreatedEvent subscribers to obtaining the parent folder from the request object, obtained via zope.globalrequest.getRequest(). This is not pretty; it is a last resort for peculiar situations.

Sean

Yep; the object hasn't been added to the tree when ObjectCreated fires. Therefor no acquisition yet.

IObjectAddedEvent did the job.

Tnx
-aj