Module status :: Class Observer
[hide private]
[frames] | no frames]

Class Observer

source code


The observer design pattern base class.

Instance Methods [hide private]
 
__init__(self, name='unknown')
Set up the object.
source code
 
notify(self)
Notify all observers of the state change.
source code
 
register(self, key, method)
Register a method to be called when the state changes.
source code
 
reset(self)
Reset the object.
source code
 
unregister(self, key)
Unregister the method corresponding to the key.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name='unknown')
(Constructor)

source code 

Set up the object.

Parameters:
  • name (str) - The special name for the observer object, used in debugging.
Overrides: object.__init__

register(self, key, method)

source code 

Register a method to be called when the state changes.

Parameters:
  • key (str) - The key to identify the observer's method.
  • method (method) - The observer's method to be called after a state change.

unregister(self, key)

source code 

Unregister the method corresponding to the key.

Parameters:
  • key (str) - The key to identify the observer's method.