Conditional decoration

Roy Smith roy at panix.com
Mon Jun 18 18:16:51 EDT 2012


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



More information about the Python-list mailing list