[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
Mon Sep 5 00:39:52 EDT 2005


Benji York wrote:
> Stuart Bishop wrote:
> 
>> If this is a way of saying "I'm iterable, but I don't want to tell you
>> how
>> long I am" 
> 
> 
> Right.
> 
>> 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.
> 
> 
> Of course, that particular spelling would be a strange way to iterate
> over the values, and a source from a non-ZODB back-end really should
> provide the C in ACID, but point taken. :)
> 
> That is the way vocabularies do it, something else might work better.
> Now would be the time to talk about it.

Urgh... I hadn't noticed that in vocabularies before. I believe this has
other side effects too, such as if I do list(mysource), Python calls
mysource.__len__ (if it exists) to preallocate the list size. Wierd things
can happen if your class lies about itself and breaks contracts.

Do you happen to know *why* the vocabularies needed this method, and if the
callsites could be fixed to catch a NotImplementedError or similar?

-- 
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/db027dad/signature.bin


More information about the Zope3-dev mailing list