Personal tools
You are here: Home Weblog Archive 2006 August 12 Overriding the form controler script for AT content
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Overriding the form controler script for AT content

by tibi last modified 2006-08-12 07:43
Filed Under:

Just like the edit form or the view page can be overriden for an AT type, so can the form controler script that would be called by the form. This recipe is lifted from SignupSheet (which I think got an inspiration from POI):

The form controler script (mytype_post.cpy):

##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind state=state
##bind subpath=traverse_subpath
##parameters=
##title=Do something
##

#do something here, like for example, changing the workflow status of the object

return state

The metadata file (mytype_post.cpy.metadata):

[actions]
action.success=redirect_to:string:${folder_url}/thank_you_message
action.failure=traverse_to_action:string:edit

And now, the magic happens in Extensions/Install.py

def addFormControllerAction(self, out, controller, template, status, 
                                contentType, button, actionType, action):
    """Add the given action to the portalFormController"""
    controller.addFormAction(template, status, contentType,
                                button, actionType, action)
    print >> out, "Added action %s to %s" % (action, template)

def Install(portal):
    controller = getToolByName(self, 'portal_form_controller')
    addFormControllerAction(self, out, controller, 'validate_integrity',
                            'success', 'MyType', None, 'traverse_to', 'string:mytype_post')

A bit of explanation: validate_integrity is the last script called in the normal AT edit process. The install script will add another transition, so after the validate_integrity is executed, next comes the mytype_post script to be executed.

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: