pydi.callback
index
/cygdrive/c/dev/workspace/pydi_open/src/pydi/callback.py

Copyright (C) 2008 Eithon Cadag
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 
callback.py - strictly-enforcing callback architecture
 
Eithon Cadag
 
Example usage:
 
 
   caller = UpdateCallBackRegister()
   obs = UpdateObserver()
   
   caller.register(obs.update) # Note: passing the METHOD itself -- not the object! We need to 
                               # declare what callbacks are acceptable to the register method for each class 
                               # using the @regcallback(<ObserverClass>,"<observer_callback_method>") decorator.
                               # This is a STRICTLY-ENFORCING callback approach.
    caller._notify(some_msg) # Actually would not be called by a third-party class, but internally; this calls the
                             # obs.update(some_msg) method.

 
Modules
       
inspect
threading
types

 
Classes
       
exceptions.Exception(exceptions.BaseException)
CallbackRegisteringError
UpdateCallBackRegister
UpdateObserver

 
class CallbackRegisteringError(exceptions.Exception)
    Raised for all exceptions due to callback errors
 
 
Method resolution order:
CallbackRegisteringError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, msg)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x6cb87ab0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class UpdateCallBackRegister
    Abstract class for observees that use an update callback
 
  Methods defined here:
__init__(self)
register = lockfnc(*args, **kwargs)

Data and other attributes defined here:
processorLock = <thread.lock object at 0x7ff120e0>

 
class UpdateObserver
    Abstract class for observers that use an update callback
 
  Methods defined here:
update(self, msg)

 
Functions
       
regcallback(cls, fnc)
Strictly-enforcing decorator for supporting class-method callbacks; this
would decorate any method that registers callbacks