+ if self._params_decoration:\r
+ for dec in self._params_decoration:\r
+ args, kwargs = dec(*args, **kwargs)\r
+\r
+ res = self._callable(*args, **kwargs)\r
+\r
+ if self._result_decoration:\r
+ for dec in self._result_decoration:\r
+ if dec._needs_params:\r
+ res = dec(res, *args, **kwargs)\r
+ else:\r
+ res = dec(res)\r
+\r
+ return res\r
+\r
+def _check_decoratable(origin, install=True):\r
+ if not isinstance(origin, DecoratableObject):\r
+ if inspect.ismethod(origin) and not hasattr(origin, '_decoratable_obj'):\r
+ decoratable = DecoratableObject(origin)\r
+\r
+ def decoratable_method(self, *args, **kwargs):\r
+ return decoratable(self, *args, **kwargs)\r
+\r
+ decoratable_method._decoratable_obj = decoratable\r
+\r
+ def decoratable_decorate(fn, mode, **kwargs):\r
+ decoratable._decorate(fn, mode, **kwargs)\r
+\r
+ decoratable_method._decorate = decoratable_decorate\r
+\r
+ if install:\r
+ setattr(origin.im_class, origin.__name__, decoratable_method)\r