NotificationCenter

Direct creation of and interation with these objects will most likely be rare as they are automatically handled by BaseObject.

NotificationCenter

class defcon.tools.notifications.NotificationCenter
addObserver(observer, methodName, notification=None, observable=None)

Add an observer to this notification dispatcher.

  • observer An object that can be referenced with weakref.
  • methodName A string epresenting the method to be called when the notification is posted.
  • notification The notification that the observer should be notified of. If this is None, all notifications for the observable will be posted to observer.
  • observable The object to observe. If this is None, all notifications with the name provided as notification will be posted to the observer.

If None is given for both notification and observable all notifications posted will be sent to the method given method of the observer.

The method that will be called as a result of the action must accept a single notification argument. This will be a Notification object.

hasObserver(observer, notification, observable)

Returns a boolean indicating if the observer is registered for notification posted by observable. Either observable or notification may be None.

removeObserver(observer, notification, observable)

Remove an observer from this notification dispatcher.

  • observer A registered object.
  • notification The notification that the observer was registered to be notified of.
  • observable The object being observed.
holdNotifications(observable=None, notification=None, observer=None)

Hold all notifications posted to all objects observing notification in observable.

  • observable The object that the notification belongs to. This is optional. If no observable is given, all notifications will be held.
  • notification The name of the notification. This is optional. If no notification is given, all notifications for observable will be held.
  • observer The specific observer to not hold notifications for. If no observer is given, the appropriate notifications will be held for all observers.

Held notifications will be posted after the matching notification and observable have been passed to Notification.releaseHeldNotifications(). This object will retain a count of how many times it has been told to hold notifications for notification and observable. It will not post the notifications until the notification and observable have been released the same number of times.

releaseHeldNotifications(observable=None, notification=None, observer=None)

Release all held notifications posted to all objects observing notification in observable.

  • observable The object that the notification belongs to. This is optional.
  • notification The name of the notification. This is optional.
  • observer The observer. This is optional.
areNotificationsHeld(observable=None, notification=None, observer=None)

Returns a boolean indicating if notifications posted to all objects observing notification in observable are being held.

  • observable The object that the notification belongs to. This is optional.
  • notification The name of the notification. This is optional.
  • observer The observer. This is optional.
disableNotifications(observable=None, notification=None, observer=None)

Disable all posts of notification from observable posted to observer observing.

  • observable The object that the notification belongs to. This is optional. If no observable is given, all notifications will be disabled for observer.
  • notification The name of the notification. This is optional. If no notification is given, all notifications for observable will be disabled for observer.
  • observer The specific observer to not send posts to. If no observer is given, the appropriate notifications will not be posted to any observers.

This object will retain a count of how many times it has been told to disable notifications for notification and observable. It will not enable new notifications until the notification and observable have been released the same number of times.

enableNotifications(observable=None, notification=None, observer=None)

Enable notifications posted to all objects observing notification in observable.

  • observable The object that the notification belongs to. This is optional.
  • notification The name of the notification. This is optional.
  • observer The observer. This is optional.
areNotificationsDisabled(observable=None, notification=None, observer=None)

Returns a boolean indicating if notifications posted to all objects observing notification in observable are disabled.

  • observable The object that the notification belongs to. This is optional.
  • notification The name of the notification. This is optional.
  • observer The observer. This is optional.

Notification

class defcon.tools.notifications.Notification(name, objRef, data)

An object that wraps notification data.

name

The notification name. A string.

object

The observable object the notification belongs to.

data

Arbitrary data passed along with the notification. There is no set format for this data and there is not requirement that any data be present. Refer to the documentation for methods that are responsible for generating notifications for information about this data.