[Zope3-Users] Lists dont accept default values

Florian Lindner mailinglists at xgm.de
Wed Feb 15 12:18:48 EST 2006


Am Mittwoch, 15. Februar 2006 14:40 schrieb Frank Burkhardt:
> Hi,
>
> I wrote a schema like this to have a list of objects on a content object:
>
>  class IMyContent(Interface):
>     mynumbers=List(
>        title=_(u"Cool Numbers"),
>        required=True,
>        value_type=Int(
>        	title=_("integer")
>        )
>        default=[1,2,3,5,7]
>     )

I think the default property expects one item of your list, so either 1, 2, 3, 
5 or 7, not all of them.
If you want to define the set of selectable values you maybe rather want to 
use a Choice field and specify the values property. Or set a Choice field as 
value for value_type.
See Stephans book [1], chapther 8.3 Core Schema Fields

[1] 
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/FrontPage/Zope3Book

Regards,

Florian


>     myline=TextLine(
>        title=_("A line of text"),
>        required=True,
>        default=u'default test'
>     )
>
> I'm using an 'addform' to add self made objects to my site but
> unfortunately the list mynumbers is not initialized with those 5 default
> numbers. The default value of myline is displayed correctly on the add
> form.
>
> Does anyone know, how this can be fixed?


More information about the Zope3-users mailing list