[Zope-dev] How to override __getattr__ and not break acquisition

Oliver Bleutgen myzope@gmx.net
Thu, 17 Oct 2002 11:24:06 +0200


John Barratt wrote:
> OK, a bit of python and Zope experimenting and I have got a little
> further with this, and my understanding as to when __getattr__ is
> actually called!
> 
> This gets closer to working, by calling the __getattr__ from the
> Implicit base class, but could be barking up the wrong tree :
> 
> def __getattr__(self,attr):
>   if name = 'foo':
>     return self.foo()
> 
>   return Implicit.__class__.__getattr__(self,attr)

If you really want to do just that, take a look at ComputedAttribute, 
just in case you don't know.

foo = ComputedAttribute(_foo)
def _foo(self,..):
     <do something>
     return something


cheers,
oliver