On Feb 16, 4:59 pm, Gustavo Narea <m...@gustavonarea.net> wrote: > I've not seen anything special in Pylons or TurboGears 2 decorators, > except that they are all functions that use the decorator package -- > while my decorator is a class that doesn't use the decorator package > yet. > > My attempt to turn that decorator into a signature preserving one > using the decorator packages fails even on TurboGears 2. As of > decorator 3.0.1, I get this error: > TypeError: You are decorating a non function: <unbound method > SecurePanel.__before__> > > Isn't this caused by the fact that my decorator is a class, or the way > such a class is defined (whose code is in the first post of the > thread)? I can turn it into a function because I'm sure I'll work -- > although I wanted a class to make it easier to customize. > > Thanks.
The decorator class is fine, the error in clearly in what you pass to the decorator. You are trying to decorate an unbound method SecurePanel.__before__: are you sure this is really what you want to decorate? Are you decorating automatically all methods of SecurePanel? I have already mentioned it, but you can extract the underlying function from the method by using SecurePanel.__before__.im_func if you really want. -- http://mail.python.org/mailman/listinfo/python-list