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