[Django] #20642: Deprecate `Option.get_(add|change|delete)_permission`.

13 views
Skip to first unread message

Django

unread,
Jun 22, 2013, 8:32:54 PM6/22/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database | Keywords:
layer (models, ORM) | Has patch: 0
Severity: Normal | Needs tests: 0
Triage Stage: | Easy pickings: 0
Unreviewed |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
In the whole ''Clean Model Options'' process we should deprecate those
methods in favor of `contrib.auth` alternatives.

Even if those methods are undocumented it's no secret they are used in the
wild. Django exclusively use them in `contrib.admin`:

{{{
(django)simon@simon-laptop:~/workspace/django$ grep -E
"get_(add|change|delete)_permission" django/ -Rn --include="*.py"
django/db/models/options.py:416: def get_add_permission(self):
django/db/models/options.py:419: def get_change_permission(self):
django/db/models/options.py:422: def get_delete_permission(self):
django/contrib/admin/options.py:355: return
request.user.has_perm(opts.app_label + '.' + opts.get_add_permission())
django/contrib/admin/options.py:369: return
request.user.has_perm(opts.app_label + '.' + opts.get_change_permission())
django/contrib/admin/options.py:383: return
request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())
django/contrib/admin/options.py:1671: self.opts.app_label + '.'
+ self.opts.get_add_permission())
django/contrib/admin/options.py:1683: opts.app_label + '.' +
opts.get_change_permission())
django/contrib/admin/options.py:1693: self.opts.app_label + '.'
+ self.opts.get_delete_permission())
django/contrib/admin/util.py:122:
opts.get_delete_permission())
}}}

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

Django

unread,
Jun 22, 2013, 10:10:32 PM6/22/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by charettes):

* has_patch: 0 => 1


Comment:

Added a patch that deprecates option permission methods and moves
`contrib.auth.management._get_permission_codename` to
`contrib.auth.get_permission_codename` and use it in `contrib.admin`.

Wondering if we should document `get_permission_codename`, it feels a bit
odd to deprecate those methods while specifying no alternatives in the
release notes.

I still pointed to it in the raised deprecation warning.

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

Django

unread,
Jun 23, 2013, 12:57:46 PM6/23/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin

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

* stage: Unreviewed => Ready for checkin


Comment:

+1 much needed cleanup.

Tested it on a project that uses permissions and
`ModelAdmin.has_x_permission` overrides extensively and didn't notice any
issue.

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

Django

unread,
Jun 24, 2013, 10:00:12 PM6/24/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by charettes):

Updated the RFC patch to use `super` in `InlineAdmin` instead of
duplicating permission codename creation.

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

Django

unread,
Jun 25, 2013, 12:23:11 PM6/25/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Database layer | Resolution: fixed

(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Simon Charette <charette.s@…>):

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


Comment:

In [changeset:"b91787910c9d5a036674d46a73d1b48ca33123a3"]:
{{{
#!CommitTicketReference repository=""
revision="b91787910c9d5a036674d46a73d1b48ca33123a3"
Fixed #20642 -- Deprecated `Option.get_(add|change|delete)_permission`.

Those methods were only used by `contrib.admin` internally and exclusively
related to `contrib.auth`. Since they were undocumented but used
in the wild the raised deprecation warning point to an also undocumented
alternative that lives in `contrib.auth`.

Also did some PEP8 and other cleanups in the affected modules.
}}}

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

Django

unread,
Jun 28, 2013, 3:36:56 PM6/28/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Simon Charette <charette.s@…>):

In [changeset:"e1dd24d2f6dd3464ab50593320a7eb2325d6c196"]:
{{{
#!CommitTicketReference repository=""
revision="e1dd24d2f6dd3464ab50593320a7eb2325d6c196"
Added missing deprecation note for model permission methods.

refs #20642.
}}}

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

Django

unread,
Jun 28, 2013, 3:51:22 PM6/28/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Simon Charette <charette.s@…>):

In [changeset:"e628753e7dd1611fb4cf770a78126e96a02ab1d7"]:
{{{
#!CommitTicketReference repository=""
revision="e628753e7dd1611fb4cf770a78126e96a02ab1d7"
[1.6.x] Added missing deprecation note for model permission methods.

refs #20642.

Backport of e1dd24d2f from master.
}}}

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

Django

unread,
Jul 1, 2013, 9:20:54 AM7/1/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"a6a905c619e48bb3db4a5fbb09e5e03abb7ed0f6"]:
{{{
#!CommitTicketReference repository=""
revision="a6a905c619e48bb3db4a5fbb09e5e03abb7ed0f6"
Updated tests for deprecation of
Option.get_(add|change|delete)_permission.

refs #20642.
}}}

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

Django

unread,
Jul 1, 2013, 9:22:03 AM7/1/13
to django-...@googlegroups.com
#20642: Deprecate `Option.get_(add|change|delete)_permission`.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master

Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"3c51962cabc9537221b86c667aac5ffaa1469660"]:
{{{
#!CommitTicketReference repository=""
revision="3c51962cabc9537221b86c667aac5ffaa1469660"
[1.6.x] Updated tests for deprecation of
Option.get_(add|change|delete)_permission.

refs #20642.

Backport of a6a905c619 from master.
}}}

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

Reply all
Reply to author
Forward
0 new messages