### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# utils.notification

## Module: `utils.notification`

Inheritance diagram for `IPython.utils.notification`:

The IPython Core Notification Center.

See docs/source/development/notification_blueprint.txt for an overview of the notification module.

Authors:

- Barry Wark
- Brian Granger

## Classes

### `NotificationCenter`

class `IPython.utils.notification.``NotificationCenter`

  Bases: `object`

  Synchronous notification center.

  Examples

  Here is a simple example of how to use this:

      import IPython.util.notification as notification
      def callback(ntype, theSender, args={}):
          print ntype,theSender,args

      notification.sharedCenter.add_observer(callback, 'NOTIFICATION_TYPE', None)
      notification.sharedCenter.post_notification('NOTIFICATION_TYPE', object()) # doctest:+ELLIPSIS
      NOTIFICATION_TYPE ...

  `__init__`()
  `add_observer`(callback, ntype, sender)

    Add an observer callback to this notification center.

    The given callback will be called upon posting of notifications of the given type/sender and will receive any additional arguments passed to post_notification.

    Parameters :

    callback : callable

    > The callable that will be called by `post_notification()` as ``callback(ntype, sender, *args, **kwargs)

    ntype : hashable

    > The notification type. If None, all notifications from sender will be posted.

    sender : hashable

    > The notification sender. If None, all notifications of ntype will be posted.

  `post_notification`(ntype, sender, *args, **kwargs)

    Post notification to all registered observers.

    The registered callback will be called as:

        callback(ntype, sender, *args, **kwargs)

    Parameters :

    ntype : hashable

    > The notification type.

    sender : hashable

    > The object sending the notification.

    *args : tuple

    > The positional arguments to be passed to the callback.

    **kwargs : dict

    > The keyword argument to be passed to the callback.

    Notes

    - If no registered observers, performance is O(1).
    - Notificaiton order is undefined.
    - Notifications are posted synchronously.
  `remove_all_observers`()

    Removes all observers from this notification center

### `NotificationError`

class `IPython.utils.notification.``NotificationError`

  Bases: `exceptions.Exception`

  `__init__`()

    x.__init__(...) initializes x; see help(type(x)) for signature

  `args`
  `message`

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »