FormController Team

by plone.org Administrator last modified Dec 05, 2005 11:05 AM

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 portal_properties / navigation_properties and 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

14:00
Pester Alan to commit his changes to Plone to avoid duplicate work and have a working example. Finished 13:50!
16:00
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
19:00
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

14:00
Converted one third of the forms We're there at six, as there are some interesting presentations during the day
19:00
Converted all forms Half way by midnight, going slow, but Wheat contributed
23:00
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

Saturday 13th

  • Try to look good on TV. :]
  • Any work done is a bonus

Sunday 14th

  • Any work done is a bonus

Monday 15th

11:00 Everything is converted, but still has to be tested.

http://plone.org/Members/geoff/cmfformcontroller

We are working on the tesdal-formcontroller-integration-branch branch of Plone, and get CMFFormController? module from collective cvs.

Set the tesdal-formcontroller-integration-base tag when starting.

List of forms ordered by navigation propertysheet:

DONE validate_id used by most forms

DONE link_edit_form, link_edit, validate_link_edit

DONE document_edit_form, document_edit, validate_document_edit

DONE newsitem_edit_form, newsitem_edit, validate_newsitem_edit

DONE image_edit_form, image_edit, validate_image_edit

DONE file_edit_form, file_edit, validate_file_edit

DONE event_edit_form, event_edit, validate_event_edit

DONE folder_edit_form, folder_edit, validate_folder_edit

DONE reconfig_form, reconfig, validate_reconfig

DONE personalize_form, personalize, validate_personalize

DONE topic_editCriteria, topic_editTopic, topic_edit_form, validate_topic_edit, folder_cut, folder_rename, folder_delete, folder_copy, folder_paste - These are specific to the Topic content type

DONE metadata_edit, metadata_edit_form, validate_metadata_edit

DONE content_status_history, validate_content_status_modify

DONE content_status_modify

DONE folder_rename

DONE folder_copy, folder_cut, folder_paste, folder_delete, folder_rename_form, folder_publish, validate_folder_rename - for all types (default)

DONE join_form, register, validate_registration

DONE createObject

DONE sendto_form, sendto, validate_sendto

DONE synPropertiesForm, editSynProperties, enableSyndication, disableSyndication, validate_synPropertiesForm

Mail from discussion with Geoff:

Ok, so based on our discussion, here's how I think we should address this:

  1. - 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.
  2. - 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.
  3. - 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:

  1. - 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?).
  2. - Take a look at the API for specifying error messages. Maybe we would be better served by having errors be objects rather than tuples?

Geoff

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)"""