[Zope3-Users] Re: zope.schema Question

Philipp von Weitershausen philipp at weitershausen.de
Sun Jul 6 18:46:14 EDT 2008


Tim Cook wrote:
> I have a class attribute defined in an interface as such:
> 
>     description=Object(
>         title=_(u"Description"),
>         description=_(u"Description of the activity."),
>         required=True,
>     )
> 
> I used Object because this attribute can be one of several different
> class instances.  
> 
> But I get an error:
> TypeError: __init__() takes exactly 2 non-keyword arguments (1 given)

Right. This is the typical error you get in Python when you're omitting 
a required parameter from a function or method call. In this case, the 
required parameter is 'schema':

   description=Object(
       schema=IFoo,
       ...
       )

So the zope.schema.Object field is really about specifying objects that 
provide a certain schema. It's not for *arbitrary* objects (use 
zope.schema.Field or zope.interface.Attribute here).



More information about the Zope3-users mailing list