[Grok-dev] sources in forms - multiple select
Jeroen Michiel
jmichiel at yahoo.com
Mon Aug 24 03:42:24 EDT 2009
That' very odd:
if this works
classesOfCompounds = schema.Choice(source=ClassesOfCompoundsSource(),
title=u'Classes of compounds')
this should also work!
classesOfCompounds = schema.List(title=u'Classes of compounds', value_type =
schema.Choice(source=ClassesOfCompoundsSource()))
maybe try with adding default=[], like this:
classesOfCompounds = schema.List(title=u'Classes of compounds', default=[],
value_type = schema.Choice(source=ClassesOfCompoundsSource()))
I can't think of anything else, really...
Thomas Bellembois-3 wrote:
>
> 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']))
>>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
>
>
--
View this message in context: http://www.nabble.com/sources-in-forms---multiple-select-tp25046327p25111829.html
Sent from the Grok mailing list archive at Nabble.com.
More information about the Grok-dev
mailing list