[silva-dev] large changes to the view system
robbenhaar at espresto.com
Tue Sep 30 20:00:09 CEST 2003
... just a short note, before I completely forget to reply:
> Over the last days I've been experimenting with a way to overhaul
> Silva's view architecture in order to support some extensibility/flexibility
> use cases. I'd like to give some information about what I've been up to
> and hopefully I'll get some feedback.
> New view system
> Views are Python classes (in Python modules on the filesystem).
> They're instantiated when they're needed to display a content object.
I guess something similar could be achieved for the widgets as well; it
seems the current directory structure maps to a class hierarchy quite
well, at least for the "edit" widgets. All the scripts and macros in the
"widgets/" directory would map to some base class, while the scripts in
the next directories "top/" and "element/" would make methods of the
some derived classes.
I am not very sure about the "mode_normal/edit/insert ... etc."
directories; I guess they may be stored as states of the instances of
the edit widget classes instead.
This possibly could help to customize the widgets, too.
If I look at the strange acquisition hook I did in the
SilvaSampleContentTypes to implement something which looks like a base
class to support xml editors for elements with a fixed number of
mandatory childs, I could guess it would make this kind of extension a
lot simpler to have class based views (or widgets, respectively).
For the public view the advantages of the "views as classes" approach
is not so big, as the possible inheritance hierarchy seems to be rather
flat, and defining a new class for every class could become soon
cumbersome ... maybe it would help to allow some kind of parametrization
(i.e. take the general view class and instantiate a "render_helper"
attribute from this file).
(Well, on the other hand, defining a new class in python is just typing
two lines of text, so the complexity of adding parametrization possibly
does not pay off).
Interestingly someone here at our local company, who did take a look at
Silva, came up with some proposal to modify the views/widgets which
looks quite similar to the current changes (except that his remarks were
not very technically detailed and far away from being implementable).
As he was new to Zope but had quite some experience with object
oriented programming he felt the way the views were organized by using
acquisition to mimic the class hierarchy of the content objects is quite
unnatural from an OO-perspective. Unfortunately he never found the time
to work out any details.
So its just a remark: if two persons have the same/similar idea
independently of each other it is usually a good sign the idea is
something reasonable ;-)
More information about the silva-dev