[Zope3-dev] proposal: replace zope.schema.Sequence with zope.schema.Collection

Gary Poster gary at zope.com
Wed Apr 28 15:28:42 EDT 2004


Stephan just implemented a chunk of the Choice/Vocabulary/Sequence ideas 
that are sketched out in the wiki 
(http://dev.zope.org/Zope3/CleanupOfSchemaAndWidgets).  I'm reviewing it 
and liking what I see for the most part.

The part that concerns me so far has nothing to do with the approach of 
the implementation but is a bit of the original plan.

In zope/schema/_field.py, Stephan implements Sequence, then subclasses 
Sequence for Tuple, List, and Set.  This is ok, since its 
implementation, but ISet also subclasses ISequence, which is wrong 
(since a set is not a sequence: it is not ordered).

IMO, Stephan has identified a clear place in which our model could be 
improved.  Rather than merely making ISet not subclass ISequence (and 
make it just subclass IField, I suppose), I propose that

    * "Sequence" be renamed to "Collection" (and "ISequence" to
      "ICollection");
    * "Collection" include an "ordered=True" keyword argument;
    * "List" and "Tuple" subclass "Collection" (and same for interfaces)
      and disallow setting of "ordered" (it must always be True);
    * "Set" subclass "Collection" (and same for interfaces) and disallow
      setting of "ordered" (it must always be False); and
    * (less importantly) "Set" default to creating a Sets.set.

If we need Sequence for backwards compatibility, it should probably be 
an alias to List.

I'll give this a whirl unless someone stops me.  Thoughts?

Gary



More information about the Zope3-dev mailing list