I've searched in Internet for a while, but I haven't found out anything useful...
I want to do something as simple as redirect the page to the listing page (folder) after save/create an AT content type.
I already know I have to use validate_integrity.cpy and write my redirect's logic there, but the file isn't run...
So far this is an example of my validate_integrity.cpy:
## Script (Python) "validate_integrity"
##title=Validate Integrity
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind state=state
##bind subpath=traverse_subpath
##parameters=
##
from Products.Archetypes import PloneMessageFactory as _
from Products.Archetypes.utils import addStatusMessage
request = context.REQUEST
errors = {}
errors = context.validate(REQUEST=request, errors=errors, data=1, metadata=0)
import pdb; pdb.set_trace()
if errors:
message = _(u'Please correct the indicated errors.')
addStatusMessage(request, message, type='error')
return state.set(status='failure', errors=errors)
else:
message = _(u'Changes saved.')
stat = 'created'
# Redirection after saving edition forms
redirects = {'Multifile': context.aq_parent.absolute_url_path() + '/multifile'}
import pdb; pdb.set_trace()
if context.portal_type in redirects:
redirect = 'redirect_to:string:${portal_url}' + redirects[context.portal_type]
state.setNextAction(redirect)
else:
stat = 'success'
addStatusMessage(request, message)
return state.set(status=stat)
RESOLUTION
I just needed to write the following upgrade step:
from Acquisition import aq_inner, aq_parent
from Products.CMFCore.utils import getToolByName
def upgrade(tool):
portal = aq_parent(aq_inner(tool))
setup = portal.portal_setup
setup.runImportStepFromProfile('profile-my.addon:default', 'skins')
Useful info about upgrade steps here
Your *.metadata file might be missing or have an action that routes to a different location than you expect: http://docs.plone.org/old-reference-manuals/forms/using_cmfformcontroller.html
The default metadata for content_edit lives in Products/Archetypes/skins/archetypes/content_edit.cpy.metadata:
...
[actions]
action.success = traverse_to:string:validate_integrity
action.success_add_reference = redirect_to:python:object.REQUEST['last_referer']
action.failure = traverse_to_action:string:edit
action.next_schemata = traverse_to_action:string:edit
Is your action button value "success"?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With