[Django] #24929: permission_required decorator should take any iterable if permissions

23 views
Skip to first unread message

Django

unread,
Jun 5, 2015, 4:06:03 AM6/5/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable if permissions
--------------------------------------+--------------------
Reporter: raphaelm | Owner:
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
As it came up in the discussion on ticket #24914 on GitHub
(https://github.com/django/django/pull/4749#discussion_r31776720), there
is no reason why permission_required only takes lists and tuples of
permissions, while `has_perm` itself can take any iterable. To be
consistent with the new mixins and other parts of Django where boths
strings and iterables of strings are accepted (see e.g.
model._meta.ordering), we should change this logic. I will prepare a pull
request with the same logic that is used in other places.

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

Django

unread,
Jun 5, 2015, 4:11:20 AM6/5/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
-------------------------------------+-------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: | Status: assigned
Cleanup/optimization |
Component: contrib.auth | Version: master
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 raphaelm):

* status: new => assigned
* needs_better_patch: => 0
* needs_tests: => 0
* owner: => raphaelm
* needs_docs: => 0
* has_patch: 0 => 1


Old description:

> As it came up in the discussion on ticket #24914 on GitHub
> (https://github.com/django/django/pull/4749#discussion_r31776720), there
> is no reason why permission_required only takes lists and tuples of
> permissions, while `has_perm` itself can take any iterable. To be
> consistent with the new mixins and other parts of Django where boths
> strings and iterables of strings are accepted (see e.g.
> model._meta.ordering), we should change this logic. I will prepare a pull
> request with the same logic that is used in other places.

New description:

As it came up in the discussion on ticket #24914 on GitHub
(https://github.com/django/django/pull/4749#discussion_r31776720), there
is no reason why permission_required only takes lists and tuples of

permissions, while `has_perms` itself can take any iterable. To be


consistent with the new mixins and other parts of Django where both

strings and iterables of strings are accepted (see e.g.
model._meta.ordering), we should change this logic. I will prepare a pull
request with the same logic that is used in other places.

--

Comment:

I created the pull request: https://github.com/django/django/pull/4790

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

Django

unread,
Jun 5, 2015, 4:29:57 AM6/5/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
--------------------------------------+------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: Cleanup/optimization | Status: assigned
Component: contrib.auth | Version: master
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 MoritzS):

* stage: Unreviewed => Accepted


Comment:

Looks good!

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

Django

unread,
Jun 5, 2015, 4:34:11 AM6/5/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
--------------------------------------+------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: Cleanup/optimization | Status: assigned
Component: contrib.auth | Version: master

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 MoritzS):

* needs_docs: 0 => 1


Comment:

Although I think you should add some documentation for this change.

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

Django

unread,
Jun 5, 2015, 5:34:51 AM6/5/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
--------------------------------------+------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: Cleanup/optimization | Status: assigned
Component: contrib.auth | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


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

Django

unread,
Jun 5, 2015, 7:14:09 AM6/5/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
--------------------------------------+------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: Cleanup/optimization | Status: assigned
Component: contrib.auth | Version: master

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 raphaelm):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0


Comment:

I added a regression test and changed one word in the documentation (list
→ iterable). Do you expect more documentation on this? If so, how? I don't
see a proper place (or a need for it).

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

Django

unread,
Jun 6, 2015, 10:12:54 AM6/6/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
-------------------------------------+-------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: | Status: assigned
Cleanup/optimization |
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | 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 timgraham):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jun 8, 2015, 1:45:11 PM6/8/15
to django-...@googlegroups.com
#24929: permission_required decorator should take any iterable of permissions
-------------------------------------+-------------------------------------
Reporter: raphaelm | Owner: raphaelm
Type: | Status: closed
Cleanup/optimization |
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed

Keywords: | 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:"39937de7e60052d3ffa9f07fdbb9262aced35d61" 39937de7]:
{{{
#!CommitTicketReference repository=""
revision="39937de7e60052d3ffa9f07fdbb9262aced35d61"
Fixed #24929 -- Allowed permission_required decorator to take any iterable
}}}

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

Reply all
Reply to author
Forward
0 new messages