| Home | Trees | Index | Help |
|
|---|
| Package wx :: Package lib :: Module pubsub |
|
This module provides a publish-subscribe component that allows listeners to subcribe to messages of a given topic. Contrary to the original wxPython.lib.pubsub module, which it is based on, it uses weak referencing to the subscribers so the subscribers are not kept alive by the Publisher. Also, callable objects can be used in addition to functions and bound methods. See Publisher class docs for more details.
Thanks to Robb Shecter and Robin Dunn for having provided the basis for this module (which now shares most of the concepts but very little design or implementation with the original wxPython.lib.pubsub).
In class Publisher, I represent the topics-listener set as a tree where each node is a topic, and contains a list of listeners of that topic, and a dictionary of subtopics of that topic. When the Publisher is told to send a message for a given topic, it traverses the tree down to the topic for which a message is being generated, all listeners on the way get sent the message.
Publisher currently uses a weak listener topic tree to store the topics for each listener, and if a listener dies before being unsubscribed, the tree is notified, and the tree eliminates the listener from itself.
Ideally, _TopicTreeNode would be a generic _TreeNode with named subnodes, and _TopicTreeRoot would be a generic _Tree with named nodes, and Publisher would store listeners in each node and a topic tuple would be converted to a path in the tree. This would lead to a much cleaner separation of concerns. But time is over, time to move on.
Version:
$Id: pubsub.py,v 1.5.2.1 2006/03/09 00:49:05 RD Exp $
Author:
Oliver Schoenborn
Copyright:
(c) 2004 Oliver Schoenborn
License:
wxWidgets
Since:
Apr 2004
| Classes | |
|---|---|
Message |
A simple container object for the two components of a message; the topic and the user data. |
| Function Summary | |
|---|---|
Function to call if, for whatever reason, you need to know explicitely what is the string to use to indicate 'all topics'. | |
test()
| |
| Variable Summary | |
|---|---|
str |
ALL_TOPICS = ''
|
Publisher |
Publisher = <wx.lib.pubsub.Publisher instance at 0xb7932...
|
| Function Details |
|---|
getStrAllTopics()Function to call if, for whatever reason, you need to know explicitely what is the string to use to indicate 'all topics'. |
| Variable Details |
|---|
ALL_TOPICS
|
Publisher
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1.20050511.rpd on Sun Mar 26 10:01:15 2006 | http://epydoc.sf.net |