From: Mike C. Fletcher [mailto:mcfletch@rogers.com]
Schoenborn, Oliver wrote:
>Yes, that was a real problem for me so I have implemented my own version
of
>pubsub, based on Robb's. There is actually very little of the original
code
>left, but Robb's pubsub certainly provided a solid base from which to
start,
>thanks Robb for that.
>
PyDispatcher has a "saferef" module which might be of interest, it
deconstructs method references into weakrefs to both object and function
so that either one going away will eliminate the callback. It's been
used quite extensively (the recipe before it especially so), and save
for actual bugs in the Python interpreter's weakref handling (all of
which appear to be fixed in Python 2.3.3) should be fairly reliable.
Thanks Mike, PyDispatcher looks great. Do you bother keeping a save ref to
the function for the method, or just the object to which the method belongs?
Interesting idea, I guess this way you cover the case of something deleting
a function from a class.
One feature that I like with pubsub is the concept of 'topics' and,
especially, the hierarchical nature of topics as supported by pubsub.
Oliver