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

Lennart Regebro lennart@torped.se
Thu, 17 Oct 2002 15:57:15 +0200


From: "John Barratt" <jjb@vivitec.com.au>
> Basically I want to do something like was demonstrated (using python
> 2.1, Zope 2.5.1), but to call the 'default' __getattr__ subsequently so
> that I can put in my own handlers, before looking for 'standard' attrs
> present on this object through the normal __getattr__ method :

There is no "default" or "normal" __getattr__. __getattr__ is defined only
when you need "abnormal" ways of getting an attribute.

> If I try a similar thing to this, I always end up getting the 'old' one
> being defined as just the 'raise' statement.

Thats because ObjectManager doesn't have a __getattr__ . The good thing with
this is that you don't have to bother about calling the normal __getattr__.
You only need to implement __getattr__ if you want data that isn't
attributes and has names that are only defined in runtime, to look like they
are attributes.

Best Regards

Lennart Regebro, Torped
http://www.easypublisher.com/