Package rats :: Module observer :: Class Observer
[hide private]
[frames] | no frames]

Class Observer

source code

object --+
         |
        Observer

Instances of Observer are notified of changes happening in the Subject instances they are attached to. It's possible for an Observer to watch many Subject.

Instance Methods [hide private]
 
__init__(self, subjects)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
append(self, subject)
Adds a subject to be observed by this Observer instance.
source code
 
update(self, origin, key, value)
Called when an attribute of the observed object is changed.
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, subjects)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

update(self, origin, key, value)

source code 

Called when an attribute of the observed object is changed. Should be overridden.

Parameters:
  • origin (any) - observed object for which the attribute is changed (caller)
  • key (string) - attribute changed (default to the function that called it. in api.py)
  • value (any) - value of the attribute after being set