Back to index

python-cliapp  1.20120630
Public Member Functions | Public Attributes
cliapp.hook.Hook Class Reference
Inheritance diagram for cliapp.hook.Hook:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def add_callback
def call_callbacks
def remove_callback

Public Attributes

 callbacks

Detailed Description

A hook.

Definition at line 30 of file hook.py.


Constructor & Destructor Documentation

def cliapp.hook.Hook.__init__ (   self)

Definition at line 34 of file hook.py.

00034 
00035     def __init__(self):
00036         self.callbacks = []
        

Member Function Documentation

def cliapp.hook.Hook.add_callback (   self,
  callback 
)
Add a callback to this hook.

Return an identifier that can be used to remove this callback.

Definition at line 37 of file hook.py.

00037 
00038     def add_callback(self, callback):
00039         '''Add a callback to this hook.
00040         
00041         Return an identifier that can be used to remove this callback.
00042 
00043         '''
00044 
00045         if callback not in self.callbacks:
00046             self.callbacks.append(callback)
00047         return callback
        
def cliapp.hook.Hook.call_callbacks (   self,
  args,
  kwargs 
)
Call all callbacks with the given arguments.

Definition at line 48 of file hook.py.

00048 
00049     def call_callbacks(self, *args, **kwargs):
00050         '''Call all callbacks with the given arguments.'''
00051         for callback in self.callbacks:
00052             callback(*args, **kwargs)
        
def cliapp.hook.Hook.remove_callback (   self,
  callback_id 
)
Remove a specific callback.

Definition at line 53 of file hook.py.

00053 
00054     def remove_callback(self, callback_id):
00055         '''Remove a specific callback.'''
00056         if callback_id in self.callbacks:
00057             self.callbacks.remove(callback_id)
00058 


Member Data Documentation

Definition at line 35 of file hook.py.


The documentation for this class was generated from the following file: