The joys of weakrefs... references to instance methods (callbacks)

Patrick K. O'Brien pobrien at orbtech.com
Mon Feb 11 20:55:33 CET 2002


You might find this useful:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056

This module, dispatcher.py, provides global signal dispatching services
suitable for a wide variety of purposes, similar to Model-View-Controller or
Model-View-Presenter patterns. This particular implementation allows a
looser coupling than most Observer patterns. It also does transparent
cleanup through the use of weak references and weak reference callbacks.
This version defaults to using weak references, but provides an option to
not use weak references for those cases where weak references are
problematic (lambdas and such).

--
Patrick K. O'Brien
Orbtech


"Mike C. Fletcher" <mcfletch at geocities.com> wrote in message
news:mailman.1013255897.29941.python-list at python.org...
> Sat down to work out a model-view framework for a little application and
> had one of those "oh, darn, didn't think that out very carefully"
> moments.  You see, I was planning on doing a fairly straightforward
> callback-passing mechanism:
>
[snip]
>
> Yes, it's slightly different semantics than weakref, but it's actually
> useful in the real world ;) .  Anyway, thought I'd share the code so
> that people can object that it's a tool of the devil :) .  If the powers
> that be want to point out any reasons why I shouldn't do this, would
> love to hear it before my house of cards goes *phoosh*.
>
> Enjoy all,
> Mike
> _______________________________________
>    Mike C. Fletcher
>    http://members.rogers.com/mcfletch/
>
>
>
>





More information about the Python-list mailing list