[Django] #25269: Method decorator should accept a iterable of decorators

8 views
Skip to first unread message

Django

unread,
Aug 13, 2015, 3:38:08 AM8/13/15
to django-...@googlegroups.com
#25269: Method decorator should accept a iterable of decorators
-------------------------------+--------------------
Reporter: zauddelig | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Hello,
The new method decorator allow to decorate a class directly. to augment
its readability I would propose to let it accept an iterable of decorator
functions.

This could be useful because it's common to decorate views using redundant
sets of decorators inside the same project or subproject, one could argue
that the same result is attained creating a new decorator or a Mixin, yet
an iterable, i. e. a tuple, seem to me more plastic and maintainable
than a class or a function.

This could be also useful if one intend to dynamically decorate
dynamically created classes although this is most probably going to be
useful in less than the 1% of the cases, so actually not significant.

The proposal introduces a polymorphic behaviour to `method_decorator`
which should now accept both function and iterables, so both the following
examples should be valid:

{{{
decorators = (
blacklist_ip,
request_is_cool,
login_required,
)

@method_decorator(decorators,"dispatch")
class ProtectedView(View):
# lot of meaningful code
pass

@method_decorator(login_required, "dispatch")
class LessProtectedView(View):
# lot of meaningful code
pass
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25269>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 13, 2015, 3:38:34 AM8/13/15
to django-...@googlegroups.com
#25269: Method decorator should accept a iterable of decorators
-------------------------------+--------------------------------------

Reporter: zauddelig | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* component: Uncategorized => Utilities
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Aug 13, 2015, 3:40:39 AM8/13/15
to django-...@googlegroups.com
#25269: Method decorator should accept a iterable of decorators
-------------------------------+--------------------------------------

Reporter: zauddelig | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by zauddelig):

* needs_docs: 0 => 1


Old description:

New description:

pull request: https://github.com/django/django/pull/5134

--

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

Django

unread,
Aug 13, 2015, 4:07:04 AM8/13/15
to django-...@googlegroups.com
#25269: Method decorator should accept a iterable of decorators
-----------------------------+--------------------------------------
Reporter: zauddelig | Owner: nobody
Type: New feature | Status: new

Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by zauddelig):

* type: Uncategorized => New feature


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

Django

unread,
Aug 13, 2015, 7:05:28 AM8/13/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+------------------------------------
Reporter: zauddelig | Owner: nobody

Type: New feature | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


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

Django

unread,
Aug 13, 2015, 10:17:11 AM8/13/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+------------------------------------
Reporter: zauddelig | Owner: nobody

Type: New feature | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by zauddelig):

I updated the pull requested:

https://github.com/django/django/pull/5134

It was added some documentation to the new behavior pretty much mimicking
the excellent one already done by zedr.

I will squash when the PR is accepted and before it is merged if that is
not a problem.

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

Django

unread,
Aug 14, 2015, 7:35:30 AM8/14/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+------------------------------------
Reporter: zauddelig | Owner: nobody

Type: New feature | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Description changed by zauddelig:

Old description:

> pull request: https://github.com/django/django/pull/5134

New description:

pull request: https://github.com/django/django/pull/5136

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:6>

Django

unread,
Aug 14, 2015, 7:37:41 AM8/14/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+------------------------------------
Reporter: zauddelig | Owner: nobody

Type: New feature | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by zauddelig):

I have done one big mess up while rebasing I closed the PR and Opened
another

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:7>

Django

unread,
Sep 7, 2015, 8:55:06 AM9/7/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+------------------------------------
Reporter: zauddelig | Owner: nobody

Type: New feature | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:8>

Django

unread,
Sep 9, 2015, 6:01:02 PM9/9/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+------------------------------------
Reporter: zauddelig | Owner: nobody

Type: New feature | Status: new
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: 1.9 | 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):

* keywords: => 1.9
* needs_better_patch: 0 => 1


Comment:

A few more updates are required but this seems to be in mostly good shape.

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:9>

Django

unread,
Sep 18, 2015, 10:02:47 AM9/18/15
to django-...@googlegroups.com
#25269: method_decorator() should accept a iterable of decorators
-----------------------------+-------------------------------------
Reporter: zauddelig | Owner: timgraham
Type: New feature | Status: assigned

Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: 1.9 | 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):

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


Comment:

I'm updating the patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:10>

Django

unread,
Sep 18, 2015, 10:31:03 AM9/18/15
to django-...@googlegroups.com
#25269: Allow method_decorator() to accept a list/tuple of decorators

-----------------------------+-------------------------------------
Reporter: zauddelig | Owner: timgraham
Type: New feature | Status: assigned
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: 1.9 | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: 1 => 0


Comment:

[https://github.com/django/django/pull/5311 Updated PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:11>

Django

unread,
Sep 18, 2015, 6:24:15 PM9/18/15
to django-...@googlegroups.com
#25269: Allow method_decorator() to accept a list/tuple of decorators
-----------------------------+---------------------------------------------

Reporter: zauddelig | Owner: timgraham
Type: New feature | Status: assigned
Component: Utilities | Version: 1.8
Severity: Normal | Resolution:
Keywords: 1.9 | Triage Stage: Ready for checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------------
Changes (by berkerpeksag):

* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/5311/ PR #5311] LGTM.

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:12>

Django

unread,
Sep 18, 2015, 7:06:45 PM9/18/15
to django-...@googlegroups.com
#25269: Allow method_decorator() to accept a list/tuple of decorators
-----------------------------+---------------------------------------------
Reporter: zauddelig | Owner: timgraham
Type: New feature | Status: closed
Component: Utilities | Version: 1.8
Severity: Normal | Resolution: fixed

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

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


Comment:

In [changeset:"186eb21dc159807dba83148f7c9c50d470745708" 186eb21d]:
{{{
#!CommitTicketReference repository=""
revision="186eb21dc159807dba83148f7c9c50d470745708"
Fixed #25269 -- Allowed method_decorator() to accept a list/tuple of
decorators.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:13>

Django

unread,
Mar 23, 2018, 5:59:00 AM3/23/18
to django-...@googlegroups.com
#25269: Allow method_decorator() to accept a list/tuple of decorators
-----------------------------+---------------------------------------------
Reporter: zauddelig | Owner: Tim Graham

Type: New feature | Status: closed
Component: Utilities | Version: 1.8
Severity: Normal | Resolution: fixed
Keywords: 1.9 | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+---------------------------------------------

Comment (by Chris Jerdonek):

FYI, I filed ticket #29253 about the implementation of this feature.

--
Ticket URL: <https://code.djangoproject.com/ticket/25269#comment:14>

Reply all
Reply to author
Forward
0 new messages