Re: Conditional decoration

2012-06-19 Thread Jean-Michel Pichavant
Roy Smith wrote: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass Hi, def my_view(request):

Re: Conditional decoration

2012-06-19 Thread Gelonida N
On 06/19/2012 02:23 AM, Rob Williscroft wrote: Roy Smith wrote in news:jro9cj$b44$1...@panix2.panix.com in gmane.comp.python.general: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view ge

Re: Conditional decoration

2012-06-18 Thread Rob Williscroft
Roy Smith wrote in news:jro9cj$b44$1...@panix2.panix.com in gmane.comp.python.general: > Is there any way to conditionally apply a decorator to a function? > For example, in django, I want to be able to control, via a run-time > config flag, if a view gets decorated with @login_required(). > > @

Re: Conditional decoration

2012-06-18 Thread Devin Jeanpierre
On Mon, Jun 18, 2012 at 6:49 PM, Emile van Sebille wrote: > On 6/18/2012 3:16 PM Roy Smith said... > class myDecorator(object): >    def __init__(self, f): >        self.f = f >    def __call__(self): >        print "Entering", self.f.__name__ >        self.f() >        print "Exited", self.f.__na

Re: Conditional decoration

2012-06-18 Thread Emile van Sebille
On 6/18/2012 3:16 PM Roy Smith said... Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass class

Re: Conditional decoration

2012-06-18 Thread MRAB
On 18/06/2012 23:16, Roy Smith wrote: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass A decora

Re: Conditional decoration

2012-06-18 Thread Jeremiah Dodds
r...@panix.com (Roy Smith) writes: > Is there any way to conditionally apply a decorator to a function? > For example, in django, I want to be able to control, via a run-time > config flag, if a view gets decorated with @login_required(). > > @login_required() > def my_view(request): > pass Y