meta classes
Carlo v. Dango
carl at hotmail.lala.com
Mon Sep 29 22:27:15 EDT 2003
hello there
I'd like to take control over the method dispatching of every subclass of a
given python class. Currently I've redefined __getattribute__() so i can
find the right instance/method to dispatch to. This works fine, albeit it
may seem a bit hackish. Further I want to control the actual dispatching,
so that I can execute methods before, after or instead of the actual
method. I would prefer to do this with the least modification of the source
due to debug'ing issues. My best idea so far is to rename every method who
subclass the magic class X and then create new methods in place of the
renamed ones, which looks up in a list to execute "before-methods", then
execute the renamed method etc..
Only I don't know how to do this. I've found some MOP code which was
designed for python old-style objects... but this is not what I want. Can
anyone kindly give me some pointers for help or some actual code?
many thanks in advance..
---
More information about the Python-list
mailing list