Intercepting __getattr__ in a Python 2.3 old-style mixin class?
"Andreas Jung" <[email protected]> Mon, 07 Nov 2016 13:01:55 +0100
| Newsgroups | gmane.comp.web.zope.devel |
|---|---|
| Message-ID | <[email protected]> |
I have a large Python 2.3 based installation with 200k LOC. As part of a migration project I need to intercept all attribute lookups of all old-style class.
Old legacy code:
class Foo(Bar):
...
My idea is to inject a common mixin class like
class Foo(Bar, Mixin):
...
class Mixin:
def __getattr__(self, k)
print repr(self), k
return Foo.__getattr__(self, k)
However I am running always into a recursion because Foo.__getattr__ resolves to Mixin.__getattr__.
(The migrated code has to run under Python 2.3 as the first step of the migration where will be moving
forward to Python 2.7 later on).
Is there any way to fix the code for Python 2.3 old-style classes?
-aj
_______________________________________________
Zope-Dev maillist - [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )
signature.asc
(application/pgp-signature, 618 B)
-----BEGIN PGP SIGNATURE----- iQGUBAEBCgAGBQJYIG00AAoJEADcfz7u4AZjxwILv0+8itbDulOjZZ1BV9a1VDKn r2Ptg5xgwM4XbILB9bY/G1OtbDBk2j+CvuaCMoMdevgY0M5ye0yNm+sPjkALUnvQ qox55Kc7k3A9yjhdtfd6sX4twYd9ZFi58tbvINNuPJUU7NsG71jS50gnn/wEXn+m wBJ/i9OuNrBf1p1ppImOYdpYY44bKH1F6i1tpuxCGiNssgOwG3LOLKSoOFCxa8tZ bHWdKf8ZHq2DVYOwGJ3PXpwlt6q32eHSPDgbodqWCjFp2JNRVpah/48AjMDhHyVl nPlnDq6dhl+f6ZPTymlx2thFywzrNw0Vn4XzPRyGdzSV3B80MLzVg74tDK6T+Q66 T6QQWyDDNXQlLgto76WPnqWjARhw7ayn8UJBZ0jC0jsLsbsRw7fkGkj+hDWuILe2 OQ/nwWSdnhE5k+ynkF6KTAGDSfMNLWnjmRBnpSXmbXOVYZCB3z4suOXtc+U6cFMF ePTTdJZhjg4dnijU3d23CWvhAuKApZ4= =WgaV -----END PGP SIGNATURE-----