]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/modules/decorators.py
remove the jquery.copy plugin, we don't need it anymore
[osqa.git] / forum / modules / decorators.py
index 3c53412dc0505c4c92bbe183a6709ca007dc5a34..11af9e3d1c4c1cd49e60b04db024a9344f7269f9 100644 (file)
@@ -69,7 +69,7 @@ class ReturnImediatelyException(Exception):
         self.ret = ret\r
 \r
 def _check_decoratable(origin, install=True):\r
-    if not isinstance(origin, DecoratableObject):\r
+    if not hasattr(origin, '_decoratable_obj'):\r
         if inspect.ismethod(origin) and not hasattr(origin, '_decoratable_obj'):\r
             decoratable = DecoratableObject(origin)\r
 \r
@@ -91,10 +91,18 @@ def _check_decoratable(origin, install=True):
         elif inspect.isfunction(origin):\r
             decoratable = DecoratableObject(origin)\r
 \r
+            def decorated(*args, **kwargs):\r
+                return decoratable(*args, **kwargs)\r
+\r
+            decorated._decoratable_obj = decoratable\r
+\r
             if install:\r
-                setattr(inspect.getmodule(origin), origin.__name__, decoratable)\r
+                setattr(inspect.getmodule(origin), origin.__name__, decorated)\r
+\r
+            decorated.__name__ = origin.__name__\r
+            decorated.__module__ = origin.__module__\r
 \r
-            return decoratable\r
+            return decorated\r
 \r
     return origin\r
 \r
@@ -103,7 +111,7 @@ def decorate(origin, needs_origin=True):
     origin = _check_decoratable(origin)\r
 \r
     def decorator(fn):\r
-        origin._decorate(fn, DecoratableObject.MODE_OVERRIDE, needs_origin=needs_origin)\r
+        origin._decoratable_obj._decorate(fn, DecoratableObject.MODE_OVERRIDE, needs_origin=needs_origin)\r
         \r
     return decorator\r
 \r
@@ -112,7 +120,7 @@ def _decorate_params(origin):
     origin = _check_decoratable(origin)\r
 \r
     def decorator(fn):\r
-        origin._decorate(fn, DecoratableObject.MODE_PARAMS)\r
+        origin._decoratable_obj._decorate(fn, DecoratableObject.MODE_PARAMS)\r
 \r
     return decorator\r
 \r
@@ -122,7 +130,7 @@ def _decorate_result(origin, needs_params=False):
     origin = _check_decoratable(origin)\r
 \r
     def decorator(fn):\r
-        origin._decorate(fn, DecoratableObject.MODE_RESULT, needs_params=needs_params)\r
+        origin._decoratable_obj._decorate(fn, DecoratableObject.MODE_RESULT, needs_params=needs_params)\r
 \r
     return decorator\r
 \r
@@ -131,7 +139,7 @@ decorate.result = _decorate_result
 def _decorate_with(fn):\r
     def decorator(origin):\r
         origin = _check_decoratable(origin)\r
-        origin._decorate(fn, DecoratableObject.MODE_OVERRIDE, needs_origin=True)\r
+        origin._decoratable_obj._decorate(fn, DecoratableObject.MODE_OVERRIDE, needs_origin=True)\r
         return origin\r
     return decorator\r
 \r
@@ -140,7 +148,7 @@ decorate.withfn = _decorate_with
 def _decorate_result_with(fn, needs_params=False):\r
     def decorator(origin):\r
         origin = _check_decoratable(origin)\r
-        origin._decorate(fn, DecoratableObject.MODE_RESULT, needs_params=needs_params)\r
+        origin._decoratable_obj._decorate(fn, DecoratableObject.MODE_RESULT, needs_params=needs_params)\r
         return origin\r
     return decorator\r
 \r
@@ -149,7 +157,7 @@ decorate.result.withfn = _decorate_result_with
 def _decorate_params_with(fn):\r
     def decorator(origin):\r
         origin = _check_decoratable(origin)\r
-        origin._decorate(fn, DecoratableObject.MODE_PARAMS)\r
+        origin._decoratable_obj._decorate(fn, DecoratableObject.MODE_PARAMS)\r
         return origin\r
     return decorator\r
 \r