Personal tools
You are here: Home Weblog Archive 2006 October 07 Little bits of info about CMFFormController
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Little bits of info about CMFFormController

by tibi last modified 2006-10-07 11:20
Filed Under:

One thing the documentation doesn't clearly state: you can set the status to a value and have that value defined as an action in the metadata file, basically redirecting the flow of the controller sequence to that action.

To make things clear, I'll paste some code. In the login_initial.cpy.metadata file from CMFPlone we have this bit of code:

[actions]
action.success=traverse_to:string:login_next
action.login_change_password=traverse_to:string:login_password

So basically we have two actions defined, depending on the type of status returned.

In the login_initial.cpy file there's this snippet:

# afterwards, change the password if necessary
if state.getKwargs().get('must_change_password',0):
    state.set(status='login_change_password')
return state

So, if the there's a 'must_change_password' in the state, the next action will be login_password.

Another method to achieve this would have been using the setNextAction method, something like this:

state.setNextAction('redirect_to:string:%s/createObject?type_name=ServiceProviderHome' % home.absolute_url())
return state

NOTE: to use setNextAction you shouldn't define any action in the metadata file. According to the documentation, 'As with the .metadata file, the default action specified in the script can be overridden via the ZMI. This allows site managers to override post-script actions without having to customize your code.'

Weblog
Atom
RDF
RSS 2.0
Powered by Quills
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: