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
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )