[Zope3-dev] Items widgets

Roché Compaan roche at upfrontsystems.co.za
Sun Oct 5 03:24:04 EDT 2003


The 'Items' widgets in the form package are not friendly to re-use and I
have a few changes that I'd like to propose.

First, the 'renderItems' method looks up items from a field's
'allowed_values':

    items = self.context.allowed_values

Items for these widgets can imaginably come from other sources, like a
query result. I propose that items either be passed in as a parameter to
'renderItems' or moved to a 'getItems' method that can easily be
overriden.

Secondly, for SingleItemsWidgets the text for an item is computed by the
'textForValue' method, but for MultiItemsWidgets it is computed by
trying to split 'item' into 'item_value' and 'item_text'. I think this
needs to be consistent for both single and multi items widgets and I tend
to favour the way MultiItemsWidget do it. 'textForValue' is cumbersome
if the values to be rendered are already html ready and you need to
convert it back to the original value to be able to get the text that
should be rendered.

Generally I think ItemsWidgets shouldn't be responsible for deciding
where there items come from, they should be provided with items. Maybe
we need an 'WidgetItemsProvider' that yields 'WidgetItem' when iterated
over and accompanying interfaces so that field values and query results
can be properly adapted for these widgets.

Any comments?

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



More information about the Zope3-dev mailing list