You are trying to set a new attribute on your Proxy
instance:
class LabelMapperProxy(object):
def __init__(self, mapper): self.mapper = mapper
This triggers a __setattr__
, which tries to access the non-existent self.mapper
attribute, so __getattr__
is consulted (which is called for all missing attributes). And __getattr__
tries to access self.mapper
....
The solution is to set mapper
directly in self.__dict__
:
class LabelMapperProxy(object):
def __init__(self, mapper): self.__dict__['mapper'] = mapper
Alternatively, use the original baseclass __setattr__
just for the mapper
attribute:
class LabelMapperProxy(object):
def __init__(self, mapper): self.mapper = mapper
def __setattr__(self, key, val):
if key == 'mapper':
return super(LabelMapperProxy, self).__setattr__(key, val)
self.mapper[key] = val