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

Joshua Immanuel <[email protected]>
Newsgroups gmane.comp.web.zope.bluebream,gmane.comp.web.zope.devel
Organization HiPro IT Solutions Private Limited
Message-ID <1311340959.2456.123.camel@jimman>
Hello Laurence,

On Fri, 2011-07-22 at 13:57 +0100, Laurence Rowe wrote:
> No, there are issues. Take this example:
> 
> >>> class ITest(Interface):
> ...  title = schema.TextLine()
> ...
> >>> ITest.names
> <bound method InterfaceClass.names of <InterfaceClass __main__.ITest>>
> >>> ITest.names()
> ['title']
> >>> ITest.description = schema.Text()
> >>> ITest.names()
> ['title']
> 
> The fields on an interface are not stored as attributes, but are
> accessible using item access, e.g: ITest['title']. You cannot assign
> that way though:
> 
> >>> ITest['description'] = schema.TextLine()
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
> TypeError: 'InterfaceClass' object does not support item assignment
> 
> Adding to an interface requires messing with the
> '_InterfaceClass__attrs' attribute of the dictionary and is
> discouraged. 

Thanks for enlightening me with this wonderful explanation. 

As Jacob mentioned, list(INode) in debug shell was very handy to debug.

-- 
Joshua Immanuel
HiPro IT Solutions Private Limited
http://hipro.co.in
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEABECAAYFAk4peZ8ACgkQWw85XwuSFMKykgCfS0MyV/3XyYyS2kfMzQHJJ7Sz
3HUAoM0gKvMOAb+F7Euhm9D7pC+dAnnn
=zZL3
-----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.