There were several discussions on the subject -- please take a look at
the list archives. Here's an additional collection of loose thoughts
that I gathered from some private E-mail exchanges:
I would suggest thinking about views in weblocks as something similar to
database views -- stateless mappings from your data model to
presentations.
Presentations should be widgets with an additional API for storing and
retrieving data.
IMO views should *NOT* be widgets. We should keep their stateless nature
and not mix in any rendering code. Instead, we should have a form object
that would use a view to a) get a list of necessary presentation
widgets, b) create and manage those presentation widgets, c) tell the
view to update presentations based on data model, d) tell the
view to update the model based on presentations and e) handle the
validation loop (asking the user to correct errors).
While we're there, we might as well do some renaming and refactoring --
I find the current dataform/quickform/datalist/dataseq/datagrid
confusing. But perhaps it's just me.
When I tried to list the things views should know or do I came up with
this:
-- maintain configuration of presentation widgets, parsers and
validators so that the entire form-processing machine may be
constructed,
-- maintain mappings between the data model (possibly multiple objects
and multiple classes) and presentation widgets (one direction goes
through parsers, the other one I do not know)
-- perform view-level validation (normally delegate validation to
presentations, it's their job, but you also want to have view-level
validators, see the :satisfies for views in weblocks)
Also:
I would say anything that can be called "part of a mapping" and is
stateless belongs in the view. Also, anything you might want to inherit
in your derived view definitions. The widget handles state and
rendering.
Hope this helps.
--J.
> I agree. I started refactoring at least the whole form widget class
> hierarchy to have an underlying form class that is essentially like a
> quickform, and building the thing that dataform is supposed to be on
> top of that (always seemed weird to me to have the larger class -
> dataform - be the base class for quickform).
To elaborate on my position regarding forms (my earlier comments
were mostly about the table widget hierarchy):
The current dataform is too rigid and bloated indeed.
There are many types of forms so it would make sense to have
a lean base class. Not necessarily quickform though.
I don't know about that -- but fact is I've been doing quite a bit of
thinking about those things. I'm sorry I couldn't quite find the time to
actually implement the code :-( It doesn't look as though I will be able
to anytime soon.
My ramblings aren't necessarily right and consistent -- I just wanted to
drop them in hoping they might be useful to someone actually doing the
work.
--J.