home go links go books go opinion go gallery go projects go resumé go
about this site
archives
book reviews
"to read" list
tech books
search books
books archive
last 10 posts
quotes
cluetrain
cluetrain (mirrored)
randobracket
image auth
search engine hits
  hit history
indexer stats
user agent list
HTML (view)
  (most up-to-date)
MS Word (dl)
code examples
doesntsuck.com
doesntsuck.com

June 24, 2005

pydispatcher   (link)

http://pydispatcher.sourceforge.net/
To be more concrete about what PyDispatcher does for you:

* provides a centralized service for delivering messages to registered objects (in the local process). It allows you to register any number of functions (callable objects) which can receive signals from senders.
o registration can be for all senders, particular sending objects, or "anonymous" messages (messages where the sender is None)
o registration can be for any signal, or particular signals
o a single signal will be delivered to all appropriate registered receivers, so that multiple registrations do not interfere with each other
* there is no requirement for the sender or receiver to be dispatcher-aware. Any Python object save the None object can act as a sender, and any callable object can act as a receiver. There is no need to inherit from a particular class or provide a particular interface on the object.
* the system uses weak references to receivers wherever possible
o object lifetimes are not affected by PyDispatcher registrations (that is, when your object goes away, the registrations related to the object also go away).
o references to common transient objects (in particular instance methods) are stored as compound weak references.
o weak references can be disabled on a registration-by-registration basis
* allows rich signal types, signals are simply hashable objects used to store and retrieve sub-tables, they are otherwise opaque to the dispatcher mechanism
* allows sending more information when sending than any particular receiver can handle, dispatcher automatically culls those arguments which are not appropriate for the particular receiver. This allows registering very simple functions dealing with general messages, while still allowing natural passing of arguments to higher level functions.

The dispatcher mechanism is particularly useful when constructing Model-View-Controller style applications where it is not desirable to have the Model objects aware of the event model.

Posted by yargevad at June 24, 2005 12:02 PM


This weblog is licensed under a Creative Commons License.