[Zope3-dev] Re: [Zope3-checkins] SVN:
Zope3/trunk/src/zope/schema/interfaces.py
- add IIterableChoice and note the desire to depricate vocabularies
Stuart Bishop
stuart at stuartbishop.net
Sun Sep 4 22:32:12 EDT 2005
Benji York wrote:
> +class IIterableSource(Interface):
> + """Source which supports iteration over allowed values.
> +
> + The objects iteration provides must be values from the source.
> + """
> +
> + def __iter__():
> + """Return an iterator which provides the values from the source."""
> +
> + def __len__():
> + """Return the number of valid values, or sys.maxint."""
If a Source is iterable, it should never have an (effectively) infinite
length, should it?
If this is a way of saying "I'm iterable, but I don't want to tell you how
long I am" (such as iterating over the results from a database query where
you would have to suck them into RAM or issue the query twice to know),
shouldn't an exeption be raised? Otherwise 'for i in range(0,len(source)):
foo = source[i]' could start blowing up if the source changes.
--
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20050905/b9b0f8ae/signature.bin
More information about the Zope3-dev
mailing list