-# Hooke is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
-# Hooke is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
-# Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
-# You should have received a copy of the GNU Lesser General Public
-# License along with Hooke. If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke. If not, see <http://www.gnu.org/licenses/>.
returned arguments of the method they're attached to.
>>> def c(self, method, *args):
returned arguments of the method they're attached to.
>>> def c(self, method, *args):
For some class, decorate any functions you're interested in
attaching callbacks too. Also, add a `_callbacks` attribute
For some class, decorate any functions you're interested in
attaching callbacks too. Also, add a `_callbacks` attribute
... return (0, 1, 1, 2, 3, 5)
...
... @callback
... def abc(self):
... "abc's docstring"
... return (0, 1, 1, 2, 3, 5)
...
... @callback
... def abc(self):
... "abc's docstring"
array of callbacks in series.
>>> def d(self, method, *args):
array of callbacks in series.
>>> def d(self, method, *args):
>>> x._callbacks['abc'] = [d, c, d]
>>> r = x.abc() # doctest: +ELLIPSIS
usual abc business
>>> x._callbacks['abc'] = [d, c, d]
>>> r = x.abc() # doctest: +ELLIPSIS
usual abc business
def new_m(self, *args, **kwargs):
result = method(self, *args, **kwargs)
callback = self._callbacks.get(method.func_name, None)
def new_m(self, *args, **kwargs):
result = method(self, *args, **kwargs)
callback = self._callbacks.get(method.func_name, None)
- nm = getattr(self, method.func_name)
+ mn = getattr(self, method.func_name)
+ log = logging.getLogger('hooke')
+ log.debug('callback: %s (%s) calling %s' % (method.func_name, mn, callback))
returned arguments of the method they're attached to.
>>> def c(self, method, *args, **kwargs):
returned arguments of the method they're attached to.
>>> def c(self, method, *args, **kwargs):
... 'callback:',
... 'class: %s' % self,
... 'method: %s' % method,
... 'args: %s' % (args,),
... 'callback:',
... 'class: %s' % self,
... 'method: %s' % method,
... 'args: %s' % (args,),
... in_callback(self, 5, my_kw=17)
... return (0, 1, 1, 2, 3, 5)
...
... def abc(self):
... "abc's docstring"
... in_callback(self, p1=3.14, p2=159)
... in_callback(self, 5, my_kw=17)
... return (0, 1, 1, 2, 3, 5)
...
... def abc(self):
... "abc's docstring"
... in_callback(self, p1=3.14, p2=159)
array of callbacks in series.
>>> def d(self, method, *args, **kwargs):
array of callbacks in series.
>>> def d(self, method, *args, **kwargs):
>>> x._callbacks['abc'] = [d, c, d]
>>> r = x.abc() # doctest: +ELLIPSIS
callback d
>>> x._callbacks['abc'] = [d, c, d]
>>> r = x.abc() # doctest: +ELLIPSIS
callback d
"""
method_name = caller_name(depth=2)
callback = self._callbacks.get(method_name, None)
"""
method_name = caller_name(depth=2)
callback = self._callbacks.get(method_name, None)
- nm = getattr(self, method_name)
+ mn = getattr(self, method_name)
+ log = logging.getLogger('hooke')
+ log.debug('callback: %s (%s) calling %s' % (method_name, mn, callback))
- cb(self, nm, *args, **kwargs)
+ cb(self, mn, *args, **kwargs)
- callback(self, nm, *args, **kwargs)
+ callback(self, mn, *args, **kwargs)