[Zope3-dev] Schema fields, widgets, allowable_values and items

Jim Fulton jim@zope.com, jim@zope.com
Sat, 02 Nov 2002 20:32:15 -0500


I've been working on the widget code and am trying to clean up the tests.
In doing so, I've discovered a bit of an inconsistency between the schema
field model and list/selection widgets.

Some fields support "allowed_values", which list the values that a field
can take. There are widgets, like ListWidgets, that allow people to select
values from the allowed values.  ListWidgets and related widgets expect fields
to have an "items" attribute.  There is no "items" attribute defined in the
field interfaces.  What's worse is that the list widget code wants items
to be a sequence of value-label pairs, although it is willing to accept a sequence of
values.  This is inconsistent with allowed_values,
which is just a sequence of values.  It seems a bit fishy for a field, which is
presentation independent, to store presentation labels, although one could
think of these as being "titles".  I want to clean this up.

I have a couple of options.  I could changes the widgets to use allowed_values,
but then they won't have separate labels. This will only affect the cache-selection
views for cachable objects at this point. These use a custom widget that could
get the labels it wants from the cache service.

I think I'll go ahead and change the widgets to use allowed_values for now.

Alternatively, we could extend allowed_values or add another field attribute to
store labels^H^H^H^H^H^Htitles.

Thoughts?

Jim.

-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (888) 344-4332            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org