Johan Carlsson [EasyPublisher] wrote:
Hi, I just read an old thread about overriding __getattr__ without breaking acquisition. Using Implicit.inheritedAttributes('__getattr__') didn't work, and I'm not sure if using Implicit.__class__.__getattr__ even gives me the correct __getattr__?
Anyway I found a way around this using __dict__ explicitly. In the __of__ wrapper I save the parent: self.__dict__['_v_parent']=parent
and in the end of __getattr__ I put
if self.__dict__.has_key('_v_parent'): return getattr(self.__dict__['_v_parent'], name)
It seams to work, but I just want to check for any problems with this approach.
Hmm, you might not need to do all of that. The acquisition wrapper first consults your __getattr__(). If your __getattr__() raises an AttributeError, the acquisition wrapper continues its search for the attribute along the normal acquisition chain. All you have to do is raise AttributeError, which you should do anyway. Shane