Package archipelcore :: Module archipelHookableEntity :: Class TNHookableEntity
[hide private]
[frames] | no frames]

Class TNHookableEntity

source code

object --+
         |
        TNHookableEntity

This class make a TNArchipelEntity hooking capable.

Instance Methods [hide private]
 
__init__(self, log)
Initialize the TNHookableEntity.
source code
 
create_hook(self, hookname)
Create a new hook.
source code
boolean
remove_hook(self, hookname)
Remove an existing hook.
source code
 
register_hook(self, hookname, method, user_info=None, oneshot=False)
Register a method that will be triggered by a hook.
source code
boolean
unregister_hook(self, hookname, method)
Unregister a method from a hook.
source code
 
perform_hooks(self, hookname, arguments=None)
Perform all registered methods for the given hook.
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, log)
(Constructor)

source code 

Initialize the TNHookableEntity.

Parameters:
  • log (TNArchipelLog) - the logger of the entity
Overrides: object.__init__

create_hook(self, hookname)

source code 

Create a new hook.

Parameters:
  • hookname (string) - the name of the new hook

remove_hook(self, hookname)

source code 

Remove an existing hook. All registered method in the hook will be removed.

Parameters:
  • hookname (string) - the name of the hook to remove
Returns: boolean
True in case of success

register_hook(self, hookname, method, user_info=None, oneshot=False)

source code 

Register a method that will be triggered by a hook. The methood must use the following prototype: method(origin, user_info, arguments).

Parameters:
  • hookname (string) - the name of the hook
  • method (function) - the method to register with the hook.
  • user_info (object) - user info you want to pass to the method when it'll be peformed
  • oneshot (boolean) - if True, the method will be unregistered after first performing

unregister_hook(self, hookname, method)

source code 

Unregister a method from a hook.

Parameters:
  • hookname (string) - the name of the hook
  • method (function) - the method to unregister from the hook
Returns: boolean
True in case of success

perform_hooks(self, hookname, arguments=None)

source code 

Perform all registered methods for the given hook.

Parameters:
  • hookname (string) - the name of the hook
  • arguments (object) - random object that will be given to the registered methods as "argument" kargs