devsup.db: add initHook() dectorator

This commit is contained in:
Michael Davidsaver
2014-12-09 11:12:24 -05:00
parent 32b8145fc7
commit 79cf57d748

View File

@ -1,6 +1,7 @@
from __future__ import print_function
import traceback
from functools import wraps
from collections import defaultdict
try:
@ -11,6 +12,7 @@ except ImportError:
__all__ = [
"hooknames",
"addHook",
"initHook",
"debugHooks",
]
@ -38,6 +40,18 @@ def addHook(state, func):
_hooktable[sid].append(func)
def initHook(state):
"""Decorator for initHook functions
@initHook("AfterIocRunning")
def myfn():
# do stuff
"""
def _add(fn):
addHook(state, fn)
return fn
return _add
def debugHooks():
"""Install debugging print to hooks
"""