You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/02/15 23:46:13 UTC

[5/10] git commit: [#5703] Refactored task decorator's handling of class tasks

[#5703] Refactored task decorator's handling of class tasks

Signed-off-by: Cory Johns <jo...@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0a0ba7a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0a0ba7a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0a0ba7a0

Branch: refs/heads/cj/5685
Commit: 0a0ba7a0ef81f1722af5d27e3cec89da66de5f4f
Parents: 0f59f64
Author: Cory Johns <jo...@geek.net>
Authored: Thu Feb 14 19:03:45 2013 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Thu Feb 14 19:10:22 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/decorators.py |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0a0ba7a0/Allura/allura/lib/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index bb5a7ff..fde5416 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -13,22 +13,15 @@ from webob import exc
 
 def task(func):
     '''Decorator to add some methods to task functions'''
-    if inspect.isclass(func):
-        return taskclass(func)
     def post(*args, **kwargs):
         from allura import model as M
         delay = kwargs.pop('delay', 0)
         return M.MonQTask.post(func, args, kwargs, delay=delay)
-    func.post = post
+    # if decorating a class, have to make it a staticmethod
+    # or it gets a spurious cls argument
+    func.post = staticmethod(post) if inspect.isclass(func) else post
     return func
 
-def taskclass(cls):
-    def post(*args, **kwargs):
-        from allura import model as M
-        return M.MonQTask.post(cls, args[1:], kwargs)
-    cls.post = classmethod(post)
-    return cls
-
 class event_handler(object):
     '''Decorator to register event handlers'''
     listeners = defaultdict(set)