Module wx.lib.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, tim to move on.
Version: $Id: pubsub.py,v 1.5 2004/05/17 19:20:48 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 |
|
getStrAllTopics ()
Function to call if, for whatever reason, you need to know
explicitely what is the string to use to indicate 'all topics'. |
|
test()
|
getStrAllTopics()
Function to call if, for whatever reason, you need to know
explicitely what is the string to use to indicate 'all topics'. -
|
ALL_TOPICS
-
- Type:
-
str
- Value:
|
Publisher
-
- Type:
-
Publisher
- Value:
<wx.lib.pubsub.Publisher instance at 0x4060a3ec>
|
|