On Feb 16, 4:59 pm, Gustavo Narea <m...@gustavonarea.net> wrote: > On Feb 16, 4:40 pm, Michele Simionato <michele.simion...@gmail.com> > wrote: > > > > > > It was broken from the beginning on Pylons. > > > > I'm a TurboGears 2 core developer, and TurboGears is powered by Pylons > > > as of version 2. The decorator has always worked in TurboGears because > > > of the way TG finds the action arguments, but now I'm working to make > > > it work in Pylons too, but this is the only problem that has stopped > > > me from making it work under Pylons. > > > > Thanks. > > > I see. I would ask on the Pylons list. I suspect a bound method is > > passed and that you will > > need to extract the corresponding function with .im_func, then making > > sure that you pass > > the self argument correctly. But this is wild guess since I have no > > idea of how Pylons decorators > > work internally as compared to TurboGears decorators. > > 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.
This is another attempt, where the decorator is a still a class but uses an auxiliary function: http://paste.chrisarndt.de/paste/38bf8a8443614464968d424e1f2d4182 However, that raises this exception: http://paste.chrisarndt.de/paste/f90bc9a058254e2ca5660882011752a7?wrap=no -- http://mail.python.org/mailman/listinfo/python-list