.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2017 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. module:: wx.lib.pubsub.pub

.. currentmodule:: wx.lib.pubsub.pub

.. highlight:: python



.. _wx.lib.pubsub.pub:

==========================================================================================================================================
|phoenix_title|  **wx.lib.pubsub.pub**
==========================================================================================================================================

This is the main entry-point to pubsub's core functionality. The :mod:`~pubsub.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
====================================

================================================================================ ================================================================================
:func:`~wx.lib.pubsub.pub.getDefaultPublisher`                                   Get the Publisher instance created by default when this module
:func:`~wx.lib.pubsub.pub.getDefaultTopicMgr`                                    Get the TopicManager instance created by default when this
:func:`~wx.lib.pubsub.pub.instantiateAllDefinedTopics`                           Loop over all topics of given provider and "instantiate" each topic, thus
:func:`~wx.lib.pubsub.pub.isSubscribed`                                          Returns true if listener has subscribed to topicName, false otherwise.
:func:`~wx.lib.pubsub.pub.isValid`                                               Return true only if listener can subscribe to messages of given topic.
:func:`~wx.lib.pubsub.pub.validate`                                              Checks if listener can subscribe to topicName. If not, raises
================================================================================ ================================================================================


|



Functions
------------

.. function:: getDefaultPublisher()

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


.. function:: getDefaultTopicMgr()

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


.. function:: 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. 


.. function:: 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. 


.. function:: isValid(listener, topicName)

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


.. function:: validate(listener, topicName)

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


