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
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
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
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
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
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
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
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