Re: [BlueBream] Referring to same interface using zope.schema.Object

Joshua Immanuel <[email protected]>
Newsgroups gmane.comp.web.zope.devel,gmane.comp.web.zope.bluebream
Organization HiPro IT Solutions Private Limited
Message-ID <1311337946.2456.105.camel@jimman>
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

_______________________________________________
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 )
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEABECAAYFAk4pbdMACgkQWw85XwuSFMJVSgCfcHj2/IP1zFLSeI+cC6IO8S9C
urYAn0f4B+oaDKARlNN58TIbQvunwE52
=gMQu
-----END PGP SIGNATURE-----
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.