[Zope-dev] __getattr__ revisited

Johan Carlsson [EasyPublisher] johanc@easypublisher.com
Wed, 16 Apr 2003 14:12:01 +0000


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.

Best Regards,
Johan Carlsson


-- 
Easy Publisher Developers Team
Johan Carlsson
johanc@easypublisher.com

Mail:
Birkagatan 9
SE-113 36  Stockholm
Sweden

Phone +46-(0)8-31 24 94
Fax +46-(0)8-673 04 44
Mobil +46-(0)70-558 25 24
http://www.easypublisher.com