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

Joshua Immanuel josh at hipro.co.in
Fri Jul 22 09:22:39 EDT 2011


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
-------------- 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/eb20651e/attachment.bin 


More information about the bluebream mailing list