[Grok-dev] sources in forms - multiple select

Thomas Bellembois thomas.bellembois at gmail.com
Fri Aug 21 05:29:27 EDT 2009


a small error in my code:

# THIS DOES NOT WORK
classesOfCompounds = schema.List(title=u'Classes of compounds', 
value_type = schema.Choice(source=ClassesOfCompoundsSource()))

TypeError: argument of type 'ClassOfCompounds' is not iterable

Thomas Bellembois wrote:
>
> On Thu, Aug 20, 2009 at 11:54 AM, Jeroen Michiel <jmichiel at yahoo.com 
> <mailto:jmichiel at yahoo.com>> wrote:
>
>
>
>     Thomas Bellembois-3 wrote:
>     >
>     > Still the same error:
>     > argument of type "ClassOfCompounds" is not  iterable
>     >
>
>     That's odd...
>     Can you post the relevant parts of your code, and perhaps a
>     traceback of the
>     error?
>     --
>
> Yes, thanks for your help.
>
> A part of my interface.py:
> class ClassesOfCompoundsSource(BasicSourceFactory):
>    
>     def getValues(self):
>         return grok.getSite().classOfCompoundsList()
>    
>     def getTitle(self, value):
>         return value.name <http://value.name>
>    
> class IMolecule(interface.Interface):
>     cas_number = schema.TextLine(title=u"CAS number")
>     ce_number = schema.TextLine(title=u"CE number")
>     remark = schema.TextLine(title=u"Remark", required = False)
>    
>     # THIS WORKS
>     classesOfCompounds = 
> schema.Choice(source=ClassesOfCompoundsSource(), title=u'Classes of 
> compounds')
>     # THIS DOES NOT WORKS
>     #classesOfCompounds = schema.List(title=u'Classes of compounds', 
> value_type = schema.Choice(['1', '2', '3']))
>



More information about the Grok-dev mailing list