[Grok-dev] Schema.List using schema.Object + schema.Choice and Source gives error in validation? Bug??

Adam Summers adamsummers1 at me.com
Fri Feb 4 06:15:37 EST 2011


Hi List,

I think I've stumbled across a bug when using schemas to validate input. Please see the app.py attached.

Please have a look at the following tests when using choices in the app.py:
1) a Simple Schema.Choice with static results -- all OK
2) a Simple Schema.Choice using sources -- all OK
3) a Schema.List which contains objects of the type used in in (1) -- all OK
4) a Schema.List which contains objects of the type used in (2) -- this cannot work

and you get the following error:

	Module zope.schema._field:325 in _validate         
>>  if value not in vocabulary:
TypeError: argument of type 'function' is not iterable 

(full traceback is also attached)

The interesting thing to note is that in the 4th test, the object 'value' has an attribute vocabulary which is set to the source function, whereas I have noted when using pdb this is usually a list of simpleterms (ie, the result of the called function).

Please let me know if I'm using the source incorrectly, I've had a frustrating two days trying to get through this.

Any help is much appreciated.

Regards,
Adam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0004.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: app.py
Type: text/x-python-script
Size: 3574 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0001.bin 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0005.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: traceback.txt
Url: http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0001.txt 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0006.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plus.jpg
Type: image/jpeg
Size: 361 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0001.jpg 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20110204/280d911a/attachment-0007.html 


More information about the Grok-dev mailing list