On 22.12.2008 11:34 Uhr, Andreas Kopecky wrote:
Hi,My first question regarding that would be: why use zope.proxy for it. Personally - not knowing what exactly you have in mind ofc - i'd use something along the lines of class Proxy(object): def __init__(self, obj): self.obj = obj def __getattr__(self, attribute): return getattr(obj, attribute) maybe add a check of the returned attribute is callable or so.
Sorry, invalid answer. That's what zope.proxy is designed for and I am trying to get it working (unlikely it has no documentation and the unittest don't give me much insight). In addition: your code won't work since you must refer to self.obj not 'obj' within __getattr__. And using self.obj will lead to an infinite recursion. I also think that __getattr__() is not used by new-styles classes. Instead you need to override __getattribute__().
Andreas
begin:vcard fn:Andreas Jung n:Jung;Andreas org:ZOPYX Ltd. & Co. KG adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany email;internet:[email protected] title:CEO tel;work:+49-7071-793376 tel;fax:+49-7071-7936840 tel;home:+49-7071-793257 x-mozilla-html:FALSE url:www.zopyx.com version:2.1 end:vcard
_______________________________________________ Zope-Dev maillist - [email protected] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
