[Zope-dev] wrapping unexistent objects
Casey Duncan
casey@zope.com
Tue, 3 Dec 2002 11:15:52 -0500
Its easy to create an infinite loop. To avoid these, do attribute lookups=
from=20
the instance __dict__ rather than directly from self:
IOW, don't do:
foo =3D self.foo
or getattr(self, 'foo')
(This can trigger another __getattr__ call)
Instead do:
foo =3D self.__dict__['foo']
(This won't cause another getattr call)
As for examples, there is a complex one in the CMF Skinnable module and a=
=20
simpler one in the Document module of my DocumentLibrary product.
-Casey
On Tuesday 03 December 2002 10:58 am, Maurizio Boriani wrote:
> >>>>> "Casey" =3D=3D Casey Duncan <casey@zope.com> writes:
>=20
> Casey> If you want an object to be able to handle calls to
> Casey> undefined methods, you'll probably need to use a
> Casey> __getattr__ hook. They can be a little tricky to get right
> Casey> (you want to filter out names that start with "_" or "aq"
> Casey> or else you'll be in trouble), and they don't have access
> Casey> to acquisition, but they will allow you to intercept calls
> Casey> to arbitrary names on an object.
>=20
> have you some examples or docs about this? I'm tring using it but my pr=
oduct
> felt in an unfinisched loop. Any suggestion
>=20
> Casey> -Casey
>=20
> TIA,
> baux
>=20