[BlueBream] [Zope-dev] Referring to same interface using zope.schema.Object

Joshua Immanuel josh at hipro.co.in
Fri Jul 22 08:32:26 EDT 2011


Hello,

On Fri, 2011-07-22 at 13:41 +0200, Jacob Holm wrote:
> On 2011-07-22 13:26, Brian Sutherland wrote:
> > This would be my first guess:
> > 
> >     class INode(Interface):
> >         pass
> >      
> >     INode.parent = Object(
> >             title=u"Parent node",
> >             schema=INode
> >             )
> > 
> >     INode.children = List(
> >             title=u'Child nodes',
> >             value_type=Object(schema=INode)
> >             )
> > 
> 

The method suggested by Brian works without any issues. :)

> 
> And that guess would be wrong.  You can't add fields to an existing
> schema like that (not sure if you can in other ways).  You *can*
> change
> an existing field however, so a working solution would be:
> 
>     class INode(Interface):
> 
>         parent = Object(
>             title = u'Parent node',
>             schema = Interface, # set to INode later
>             )
> 
>         children = List(
>             title = u'Child nodes',
>             value_type = Object(schema=Interface), 
>             )
> 
>     INode['parent'].schema = INode
>     INode['children'].value_type.schema = INode 

I thought this also should work without any issues. But when I ran the
debug shell to list out the attributes of INode using dir(INode) I
couldn't find the 'parent' and 'children' attributes in it. Even worse
part is, if there is another field say

                name = TextLine(title=u'Node name')
                
This 'name' attribute is also is not visible along with 'parent' and
'children' attributes.

Can someone explain why is this so?

(Even though the problem gets solved by Brian's method, just curious to
know)
-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/bluebream/attachments/20110722/44ff9669/attachment.bin 


More information about the bluebream mailing list