[Zope3-Users] Interfaces in Schemas
Hermann Himmelbauer
dusty at qwer.tk
Thu Apr 19 10:50:12 EDT 2007
Am Mittwoch, 18. April 2007 23:24 schrieb Darryl Cousins:
> Hi,
>
> On Wed, 2007-04-18 at 09:21 -0700, Martin Aspeli wrote:
> > Hermann Himmelbauer wrote:
> > > Hi,
> > > I wonder if it's possible to define attributes in a schema that
> > > reference other interfaces. For instance, I have a schema for a car and
> > > another one for
> > > a wheel and what I want to do is something like that:
> > >
> > > class IWheel(Interface):
> > > type = TextLine()
> > >
> > > class ICar(Interface):
> > >
> > > model = TextLine()
> > >
> > > wheel = ??? of type IWheel ???
> >
> > wheel = schema.Object(schema=IWheel)
> >
> > > or even better:
> > > wheel = List(min_length=4, max_length=4,
> > > value_type = ??? of type IWheel???)
> >
> > value_type=schema.Object(schema=IWheel)
> >
> > > What would be really great now is if formlib could handle this and
> > > would automatically set up the needed widgets.
> >
> > Not sure what it does; I think you'd need to write some custom reference
> > widget type thing; you can't "fill in a wheel", really. :) Where would
> > the Wheel objects come from?
>
> This tutorial will be enough to get you started with a custom widget for
> your List->Object field.
>
> http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent
Ah, that's very nice, thanks!
Tried it out and it seems to work for Objects() in the schema. However, for
Lists(value_type=Object()), I get permission problems:
ForbiddenAttribute: ('__getitem__', [<zbsp.fp.Email object at 0x31eed90>])
This happens whenever I try to access the list in any way (e.g. mylist[0] or
for i in mylist...). So it seems, I have to declare permissions for this
list - but how? For the generic Python list object?
My permissions are declared like this:
<class class=".fp.MyObj">
<require
permission="zope.View"
interface=".interfaces.IMyObj"
/>
<require
permission="zope.ManageContent"
set_schema=".interfaces.IMyObj"
/>
</class>
I thought this would suffice?
Best Regards,
Hermann
Best Regards,
Hermann
--
x1 at aon.at
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
More information about the Zope3-users
mailing list