I\'m wanting to redirect to a container\'s parent after deleting an item within it. To this end, I\'ve tried subscribing to zope.lifecycleevent\'s IObjectRemovedEvent<
Instead of using a event handler, you could customize the delete_confirmation
actions; these can be altered through the web even, and can be customized per type. The delete_confirmation
script is a CMF Form Controller script and there are several options to alter it's behaviour.
Currently, the actions are defined as such:
[actions]
action.success=redirect_to:python:object.aq_inner.aq_parent.absolute_url()
action.confirm=traverse_to:string:delete_confirmation_page
You could add a type specific action by defining action.success.TypeName
, for example.
To do so through-the-web, visit the ZMI and find the portal_form_controller
tool, then click the Actions
tab:
As you can see in this screenshot there is also documentation on the tool available here.
On the actions tab there is a form to add new actions:
As you can see, the context type is a drop-down with all existing type registrations to make it easier to specify a type-specific action. I've copied in the regular action (a redirect_to
action specified by a python:
expression and added an extra .aq_parent
to select the container parent.
You could also add such an action with the .addFormAction
method on the tool:
fctool = getToolByName(context, 'portal_form_controller')
fctool.addFormAction('delete_confirmation', 'success', 'Event', None,
'redirect_to',
'python:object.aq_inner.aq_parent.aq_parent.absolute_url()')
Last, but not least, you can specify such custom actions in the cmfformcontroller.xml
file in a GenericSetup profile; here is an example based on the above action:
This format is one of those under-documented things in Plone; I got this from the CMFFormController sourcecode for the GS import and export code.