diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-05-07 10:44:36 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-05-07 10:44:36 +0200 |
commit | b61e1467ee19ca96782248c0189424334d5980b7 (patch) | |
tree | cb7b7283f725efe9a525e81f535d22cb2a287e54 /module/plugins/Hook.py | |
parent | merged (diff) | |
download | pyload-b61e1467ee19ca96782248c0189424334d5980b7.tar.xz |
hooks methods callable via rpc, closed #299
Diffstat (limited to 'module/plugins/Hook.py')
-rw-r--r-- | module/plugins/Hook.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 4af6a0ed4..c9d9c8778 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -20,6 +20,20 @@ from thread import start_new_thread + +class Expose(object): + """ used for decoration to declare rpc services """ + def __init__(self, *args, **kwargs): + self._f = args[0] + hookManager.addRPC(self._f.__module__, self._f.func_name, self._f.func_doc) + + def __get__(self, obj, klass): + self._obj = obj + return self + + def __call__(self, *args, **kwargs): + return self._f(self._obj, *args, **kwargs) + def threaded(f): def run(*args,**kwargs): return start_new_thread(f, args, kwargs) |