python - Plone Archetypes redirection after creation -
i've searched in internet while, haven't found out useful...
i want simple redirect page listing page (folder) after save/create @ content type.
i know have use validate_integrity.cpy , write redirect's logic there, file isn't run...
so far example of 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= ## products.archetypes import plonemessagefactory _ 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 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 needed write following upgrade step:
from acquisition import aq_inner, aq_parent 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')
your *.metadata file might missing or have action routes different location expect: http://docs.plone.org/old-reference-manuals/forms/using_cmfformcontroller.html
the default metadata 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 action button value "success"?
Comments
Post a Comment