Module nodenet.eventhook

Module Summary

class EventHook:
    def __init__(self, name=None)
EventHooks are used to manage a list of callbacks.

Classes

The EventHook Class

EventHook(name=None)

EventHooks are used to manage a list of callbacks. Event hooks themselves are callable objects, and when called they will call each callback in their list until one of the callbacks returns a true value. That value is then returned by the EventHook.

Parameters:

name -- a string describing the calling convention of the event hook

Event hooks:

on_add_callback(eventhook, callback)

Called when a callback is added to the event hook. Return true to prevent the addition of that callback.

on_remove_callback(eventhook, callback)

Called when a callback is removed from the event hook. Return true to abort the removal.

Method Summary

__call__(*param, **key)
Calls all the callbacks hooked into this event hook until a callback returns a true value.
add_callback(callback)
Add a new callback to the end of the internal callback list.
add_callback_after(callback, after_callback=None)
Add a new callback after the specified callback.
add_callback_before(callback, before_callback=None)
Add a new callback before the specified callback.
get_callback_list()
Returns a list of all the callbacks hooked in to the event hook.
remove_callback(callback)
Removes a callback from the event hook.

__call__

__call__(*param, **key)

Calls all the callbacks hooked into this event hook until a callback returns a true value. The event hook will then return that true value.

add_callback

add_callback(callback)

Add a new callback to the end of the internal callback list.

add_callback_after

add_callback_after(callback, after_callback=None)

Add a new callback after the specified callback. If after_callback is None, the new callback is added to the end of the list.

add_callback_before

add_callback_before(callback, before_callback=None)

Add a new callback before the specified callback. If before_callback is None, the new callback is added to the beginning of the list.

get_callback_list

get_callback_list()

Returns a list of all the callbacks hooked in to the event hook.

remove_callback

remove_callback(callback)

Removes a callback from the event hook.