I´m no decorator guru myself, but i dont think that decorators have to
return functions necessarily. But I had also tried what you suggested,
that gives me an exception:
exceptions.TypeError: 'NoneType' object is not callable
On Jun 17, 10:05 am, Christoph Haas <[EMAIL PROTECTED]> wrote:
> On Sun, Jun 17, 2007 at 12:47:47AM -0700, voltron wrote:
> > I am having problems using decorators with controllers. In a test
> > controller:
>
> > # testcontroller.py
>
> > def dec(func):
> > # do lotsa things
> > print "im doing something"
> > finished = True
> > if finished:
> > func() # call the function you were decorating
>
> > class HomeController(BaseController):
> > def index(self):
> > return render_response('index.html')
>
> > @dec(home)
> > def test(self):
> > return render_response('test.html')
>
> > tryinf this, I get an error:
> > exceptions.TypeError: home() takes exactly 1 argument (0 given)
>
> > I have to pass "self" to the function passed to the decorator somehow,
> > what would be the best way to do this? I want the decorator to carry
> > out a few things before calling the controller function its
> > decorating.
>
> I'm no decoration guru. But don't you have to "return func" in the
> decorator?
>
> Christoph
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---