The Form Controller Team Page (Participates in: DocumentationTeam)
The task is growing. To make the security satisfactory we need to add validation to scripts. Geoff doesn't have time this week.
FormController also provides an optional message id to improve i18n for error messages. This should be updated aswell. The API is at the bottom of this page.
FormController should be used everywhere
form_properties are used now, which is ~20 templates.
Look at the FormControllerMigrationHowTo if you want to transition to the framework see how it works
Leader: Helge Tesdal
Participants: Maik Röder, Lukas Auersperg
Milestones Thursday 11th
- Pester Alan to commit his changes to Plone to avoid duplicate work and have a working example. Finished 13:50!
- Documentation on how to convert a form to use the FormController. This is both for product authors and for us to follow when converting forms. Took longer than expected, but now both Lukas and Maik got a good understanding of how it works
- Converted at least half of the forms. Converted one, but need to think about validation for scripts, want to find best practice
Milestones Friday 12th
- Converted one third of the forms We're there at six, as there are some interesting presentations during the day
- Converted all forms Half way by midnight, going slow, but Wheat contributed
- Prepare for modifying CMFFormController? itself to add validation to scripts, not just forms. Change meta type to Controller instead of Controlled script/template. Postponed until tomorrow
- Try to look good on TV. :]
- Any work done is a bonus
- Any work done is a bonus
11:00 Everything is converted, but still has to be tested.
We are working on the
tesdal-formcontroller-integration-branch branch of Plone, and get CMFFormController? module from collective cvs.
tesdal-formcontroller-integration-base tag when starting.
List of forms ordered by navigation propertysheet:
validate_id used by most forms
folder_paste - These are specific to the Topic content type
- for all types (default)
Mail from discussion with Geoff:
Ok, so based on our discussion, here's how I think we should address this:
- - Modify BaseControlledPythonScript?.py so that controlled python scripts have validators associated with them in addition to actions. You'll also need to make minor modifications to FSControlledPythonScript?.py and to ControlledPythonScript?.py. Also, you will need to modify the associated page template files so that people can specify validators TTW. Most of the modifications will involve copying code from controlled page template files.
- - Move the guts of BaseControlledPageTemplate?.validate to FormController. Have the new validate method grab a list of validators that have already run from the ControllerState? object. Then have it call all the validators not on the list. Once it's done, have it insert a new list of validators called into the ControllerState? object. Have BaseControlledPageTemplate? call the new FormController validate method and have FSControlledPythonScript? and ControlledPythonScript? call FormController.validate.
- - Decide upon a default action for scripts when they return failure. Probably the sanest thing would be to have them kick you over to an error page (that you will need to define) that dumps the error dictionary from ControllerState?.
- One issue to resolve: what if you have a validator that needs to run multiple times? e.g. I want to chain a bunch of scripts together using the traverse_to action, each script modifies some REQUEST variable, and i want to validate that variable for each new script. What happens? Maybe there needs to be a "force all validators to run" option somewhere?
A few other things to do:
- - Modify Actions/TraverseToAction? and Actions/RedirectToAction? so that they use listFilteredActionsFor to get the action rather than getActionById (since getActionById does not include actions provided by other ActionProviders?).
- - Take a look at the API for specifying error messages. Maybe we would be better served by having errors be objects rather than tuples?
i18n API for errors:
def setError(self, id, message, msgid=None, new_status=None): """Add an error message to the current state object. The new_status argument allows you to optionally change the object's status.""" def getError(self, id): """Return the error message associated with the form variable id""" err = self.errors.get(id, None) def getI18NError(self, id): """Return the error message and i18n msgid associated with the form variable id. The return value is the tuple (errmsg, i18n_msgid).""" def getErrors(self): """Return all errors in a dict of the form dict['name']<a class="new visualNoPrint" href="http://new.plone.org/events/sprints/castlesprint/wiki/FormControllerTeam/createform?page=%27name%27" title="create this page">?</a> = errmsg""" def getI18NErrors(self): """Return all errors in a dict of the form dict['name']<a class="new visualNoPrint" href="http://new.plone.org/events/sprints/castlesprint/wiki/FormControllerTeam/createform?page=%27name%27" title="create this page">?</a> = (errmsg, i18n_msgid)"""