[Zope-dev] Proxy Object / __getattr__ / Acquisition
Dieter Maurer
dieter@handshake.de
Fri, 30 Aug 2002 21:55:35 +0200
sean.upton@uniontrib.com writes:
> ....
> I am using __getattr__ within my product, and the code
> pasted below works ...
> However, because of the way that this
> messes with Acquisition, certain things like accessing the ZMI pages or
> acquired methods can be quite slow (but work).
> ...
> def __getattr__(self, name):
> return getattr(self._CurrentVersion, name)
I am (almost) sure, you run into the same problem than I did
and reported to <mailto:zpt@zope.org>.
You get an infinite "__getattr__" loop, broken via
a "RuntimeError, maximal recursion exceeded" which is silently
ignored.
Use
def __getattr__(self,name):
# avoid acquisition
current= self.__dict__['_CurrentVersion']
if hasattr(current,name):
return getattr(self._CurrentVersion,name)
More info in the ZPT mailing list archives.
Dieter