#25146: Allow method_decorator to work at the class level
-------------------------------+------------------------------
Reporter: georgebrock | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords: method_decorator
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------
Allowing `method_decorator` to be applied at the class level would avoid
situations where a superclass method is re-declared, just to apply a
decorator.
The following would be equivalent:
{{{
#!python
class ProtectedView(generic.TemplateView):
template_name = 'secret.html'
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(ProtectedView, self).dispatch(*args, **kwargs)
}}}
{{{
#!python
@method_decorator(login_required, name='dispatch')
class ProtectedView(generic.TemplateView):
template_name = 'secret.html'
}}}
This idea comes from a comment by timgraham on #25138.
--
Ticket URL: <https://code.djangoproject.com/ticket/25146>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.7d708e1403a0acc4c9dafbac481f1005%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.