[Seaside] Initialisation of componentClass

Iwan Vosloo iwan at reahl.org
Mon May 16 10:09:07 UTC 2016


Hi there,

We have an issue related to magritte-seaside.

When you set the Component to be used on a MADescription, eg:

descriptionThings
   ^ MAToManyRelationDescription new
          ...
          componentClass: MyFancyTableComponent;
          yourself

.. then there is no way (that I am aware of) to initialize the created 
MyFancyTableComponent in a customised way.

In the example above, for instance one may have a MyFancyTableComponent 
that divides its items into several pages (like an MAReport would do). 
The number of items displayed per page has to be hard-coded in 
MyFancyTableComponent. It would be nice to have a way to initialize a 
newly created instance, something like:

descriptionThings
   ^ MAToManyRelationDescription new
          ...
          componentClass: MyFancyTableComponent;
          initializeComponent: [ :newlyCreatedComponent| 
newlyCreatedComponent itemsPerPage: 40 ];
          yourself

There are, of course, several ways one could do this. I am not 
necessarily suggesting the above example as the way to do it... I am 
just illustrating the point.

If you do not have such a mechanism, the only thing you can do is 
subclass MyFancyTableComponent with the express motivation - to be able 
to set a new instance up a certain way. We have a log of code that does 
this sort of subclassing. It makes things go really messy eventually. 
We'd like to get rid of all those subclasses and rather let the user of 
a component 'configure' it appropriately.

Building something like what I am proposing means changes to 
magritte-seaside code though. So, if we do it we'd prefer to contribute 
upstream.

Has anyone else come across this issue? Any ideas? Worthwhile to others too?

Regards
- Iwan

-- 
Reahl, the Python only web framework: http://www.reahl.org



More information about the seaside mailing list