[Django] #26470: Checks performed during Permission creation should use the check framework.

21 views
Skip to first unread message

Django

unread,
Apr 6, 2016, 1:11:50 AM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
------------------------------------------------+------------------------
Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
The `django.contrib.auth.management.check_permission` function that is
connected to the `post_migrate` signal performs static model analysis
checks that should rely on the check framework. At the moment a
`ValidationError` or a `CommandError` is raised when a check fails.

The checks performed are the following:

1. Check that custom permissions don't clash with built-ins and are not
duplicated;
2. Check that models `verbose_name` doesn't exceed a certain length based
on the `Permission.name.max_length`;
3. Check that permissions `name` doesn't exceed a certain length based on
the `Permission.name.max_length`.

For `2.` and `3.` I suggest we make them issue a `check.Warning` with a
message noting that the name will be truncated to N characters instead of
crashing with an `IntegrityError` if the check is ignored/disabled.

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

Django

unread,
Apr 6, 2016, 1:14:16 AM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
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 charettes):

* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Apr 6, 2016, 8:30:05 AM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
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: Unreviewed => Ready for checkin


Comment:

Those checks were added before the permission name `max_length` was
increased from 50 to 255 (#8162). Therefore I expect few if any users to
exceed that limit these days. I don't see much benefit to adding
truncation logic as proposed.

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

Django

unread,
Apr 6, 2016, 10:37:10 AM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted


Comment:

Alright, I'll add them as errors later today in this case.

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

Django

unread,
Apr 6, 2016, 2:26:54 PM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by charettes):

Just ported the permission names max length checks as well.

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

Django

unread,
Apr 6, 2016, 2:27:01 PM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
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 charettes):

* needs_better_patch: 1 => 0


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

Django

unread,
Apr 6, 2016, 8:55:22 PM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
Type: | Status: new
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/26470#comment:6>

Django

unread,
Apr 6, 2016, 11:04:38 PM4/6/16
to django-...@googlegroups.com
#26470: Checks performed during Permission creation should use the check framework.
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: nobody
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 Simon Charette <charette.s@…>):

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


Comment:

In [changeset:"a872194802c2bacb067c2b9c9cb76361e2071c0f" a872194]:
{{{
#!CommitTicketReference repository=""
revision="a872194802c2bacb067c2b9c9cb76361e2071c0f"
Fixed #26470 -- Converted auth permission validation to system checks.

Thanks Tim for the review.
}}}

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

Reply all
Reply to author
Forward
0 new messages