[Django] #25146: Allow method_decorator to work at the class level

42 views
Skip to first unread message

Django

unread,
Jul 20, 2015, 9:13:17 AM7/20/15
to django-...@googlegroups.com
#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.

Django

unread,
Jul 20, 2015, 9:38:05 AM7/20/15
to django-...@googlegroups.com
#25146: Allow method_decorator to work at the class level
----------------------------------+------------------------------------

Reporter: georgebrock | Owner: nobody
Type: New feature | Status: new
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: method_decorator | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* component: Uncategorized => Utilities
* needs_tests: => 0
* version: 1.8 => master
* needs_docs: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/25146#comment:1>

Django

unread,
Jul 21, 2015, 3:15:53 AM7/21/15
to django-...@googlegroups.com
#25146: Allow method_decorator to work at the class level
----------------------------------+------------------------------------
Reporter: georgebrock | Owner: zedr
Type: New feature | Status: assigned

Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: method_decorator | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by zedr):

* status: new => assigned
* owner: nobody => zedr


Comment:

Taking a look at it...

--
Ticket URL: <https://code.djangoproject.com/ticket/25146#comment:2>

Django

unread,
Jul 21, 2015, 5:06:36 PM7/21/15
to django-...@googlegroups.com
#25146: Allow method_decorator to work at the class level
----------------------------------+------------------------------------
Reporter: georgebrock | Owner: zedr
Type: New feature | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: method_decorator | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by zedr):

* has_patch: 0 => 1


Comment:

Pull request: https://github.com/django/django/pull/5031

--
Ticket URL: <https://code.djangoproject.com/ticket/25146#comment:3>

Django

unread,
Jul 28, 2015, 7:23:31 PM7/28/15
to django-...@googlegroups.com
#25146: Allow method_decorator to work at the class level
----------------------------------+------------------------------------
Reporter: georgebrock | Owner: zedr
Type: New feature | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: method_decorator | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/25146#comment:4>

Django

unread,
Aug 1, 2015, 8:38:40 AM8/1/15
to django-...@googlegroups.com
#25146: Allow method_decorator to work at the class level
----------------------------------+------------------------------------
Reporter: georgebrock | Owner: zedr
Type: New feature | Status: closed
Component: Utilities | Version: master
Severity: Normal | Resolution: fixed

Keywords: method_decorator | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3bdaaf6777804d33ee46cdb5a889b8cc544a91f1" 3bdaaf67]:
{{{
#!CommitTicketReference repository=""
revision="3bdaaf6777804d33ee46cdb5a889b8cc544a91f1"
Fixed #25146 -- Allowed method_decorator() to decorate classes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25146#comment:5>

Reply all
Reply to author
Forward
0 new messages