[TransWarp] State of the Onion (updates to current release plans)

Roché Compaan roche at upfrontsystems.co.za
Fri Aug 8 07:54:16 EDT 2003


* Phillip J. Eby <pje at telecommunity.com> [2003-08-08 01:29]:
> Very Important:
> 
> * Forms - we need a form widgets framework  (much easier said than done, 
> since we haven't defined precisely what that means, yet)

Let me try. 

The problem as I see it is that it is tedious to code HTML forms, make
them sticky and validate their input and they are generally more
difficult to reuse than what is possible in python. There are also
enough similarities between the add form, edit form, list view and
record view of an object that makes coding a template for each feel even
more tedious and often leads to a lot of inconsistency in the ui.

To start of with we need a set of widgets. A widget is a python class
that knows how to render itself as HTML. A widget can render a default
if supplied or render a value if passed one.

Next we need to assemble widgets into a collection that can be offered
by a Decorator to a template for rendering. We call this a WidgetSet.
Widgets in the WidgetSet must have order.

We need DOMLets that can iterate over a WidgetSet and render its
widgets. These DOMLets are also responsible for supplying the widgets
with values. First they should check if there is a value on the request
and then on the subject, so the values on the request overrides.

For forms, the values should be validated when a POST occurs. I think
this can be much simpler than I initially thought. A Decorator calls
applyChanges on the WidgetSet that first tries to apply changes to the
underlying object and then calls validate to do any extra validation.
applyChanges gets context and object as arguments and uses the keys of
the widgets in the WidgetSet to lookup values in the request and apply
it to the object. If there are any failures exceptions are raised and
stored in an errors data structure.

If there were errors they should be available to templates for
rendering. I'm unclear on how this will work. Can the errors just be set
on the request object? This will only work if we return the template in
the same request, otherwise errors will have to be saved on the session.
DOMLets rendering form errors should then look on both the request and
session for errors.

Feel free to fill in missing details or suggest changes.

-- 
Roché Compaan
Upfront Systems                 http://www.upfrontsystems.co.za



More information about the PEAK mailing list