Re: Referring to same interface using zope.schema.Object

Brian Sutherland <[email protected]>
Newsgroups gmane.comp.web.zope.devel,gmane.comp.web.zope.bluebream
Message-ID <[email protected]>
On Fri, Jul 22, 2011 at 04:29:32PM +0530, Joe Steeve wrote:
> Hello,
> 
> I am trying to construct an object tree. Every node in the tree is of
> the same type. I am trying to achieve something like:
> 
>         class INode(Interface):
>         
>             parent = Object(
>                 title=u"Parent node",
>                 schema=INode
>                 )
>         
>             children = List(
>                 title=u'Child nodes',
>                 value_type=Object(schema=INode)
>                 )
> 
> The above fails with "NameError: name 'INode' is not defined". Any clues
> as to how to solve this?

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)
            )

-- 
Brian Sutherland
_______________________________________________
Zope-Dev maillist  -  [email protected]
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 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.