hooks work

This commit is contained in:
Michael Davidsaver
2013-03-24 21:14:31 -04:00
parent 23d134540b
commit f58ba8dccb
4 changed files with 79 additions and 23 deletions

View File

36
python/devsup/hooks.py Normal file
View File

@@ -0,0 +1,36 @@
from _dbapi import _hooks, _hooktable
__all__ = [
"hooknames",
"addHook",
"debugHooks",
]
hooknames = _hooks.keys()
def addHook(state, func):
"""addHook("stats", funcion)
Add callback function to IOC start sequence.
def show():
print 'State Occurred'
addHook("AfterIocRunning", show)
"""
sid = _hooks[state]
try:
slist = _hooktable[sid]
except KeyError:
slist = []
_hooktable[sid] = slist
slist.append(func)
def debugHooks():
"""Install debugging print to hooks
"""
for h in hooknames:
def _showstate(state=h):
print 'Reached state',state
addHook(h, _showstate)