phoenix_title wx.lib.pubsub.pub

This is the main entry-point to pubsub’s core functionality. The pub module supports:

  • messaging: publishing and receiving messages of a given topic

  • tracing: tracing pubsub activity in an application

  • trapping exceptions: dealing with “badly behaved” listeners (ie that leak exceptions)

  • specificatio of topic tree: defining (or just documenting) the topic tree of an application; message data specification (MDS)

The recommended usage is

from pubsub import pub

// use pub functions:
pub.sendMessage(...)

Note that this module creates a “default” instance of pubsub.core.Publisher and binds several local functions to some of its methods and those of the pubsub.core.TopicManager instance that it contains. However, an application may create as many independent instances of Publisher as required (for instance, one in each thread; with a custom queue to mediate message transfer between threads).

function_summary Functions Summary

getDefaultPublisher

Get the Publisher instance created by default when this module

getDefaultTopicMgr

Get the TopicManager instance created by default when this

instantiateAllDefinedTopics

Loop over all topics of given provider and “instantiate” each topic, thus

isSubscribed

Returns true if listener has subscribed to topicName, false otherwise.

isValid

Return true only if listener can subscribe to messages of given topic.

validate

Checks if listener can subscribe to topicName. If not, raises


Functions



getDefaultPublisher()

Get the Publisher instance created by default when this module is imported. See the module doc for details about this instance.



getDefaultTopicMgr()

Get the TopicManager instance created by default when this module is imported. This function is a shortcut for pub.getDefaultPublisher().getTopicMgr().



instantiateAllDefinedTopics(provider)

Loop over all topics of given provider and “instantiate” each topic, thus forcing a parse of the topics documentation, message data specification (MDS), comparison with parent MDS, and MDS documentation. Without this function call, an error among any of those characteristics will manifest only if the a listener is registered on it.



isSubscribed(listener, topicName)

Returns true if listener has subscribed to topicName, false otherwise. WARNING: a false return is not a guarantee that listener won’t get messages of topicName: it could receive messages of a subtopic of topicName.



isValid(listener, topicName)

Return true only if listener can subscribe to messages of given topic.



validate(listener, topicName)

Checks if listener can subscribe to topicName. If not, raises ListenerMismatchError, otherwise just returns.