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

type 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, method_name=None)
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
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, method_name=None)

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.
  • method_name (str or None) - The optional method name used in debugging printouts.

unregister(self, key)

source code 

Unregister the method corresponding to the key.

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