[Django] #28766: Add route information to ResolverMatch

52 views
Skip to first unread message

Django

unread,
Nov 2, 2017, 12:30:49 PM11/2/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
---------------------------------------------+------------------------
Reporter: Benjamin Wohlwend | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 2.0
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 new route-based URL patterns are fantastic, but when introspecting the
ResolverMatch object, the route information is not available. The route
would be of great use for tools/libraries that need to introspect the URL
resolver.

GitHub PR with a first try at adding this will follow.

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

Django

unread,
Nov 2, 2017, 12:38:39 PM11/2/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned

Component: Core (URLs) | Version: 2.0
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 Benjamin Wohlwend):

* status: new => assigned
* owner: nobody => Benjamin Wohlwend
* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/9323

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

Django

unread,
Nov 4, 2017, 10:06:05 AM11/4/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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 Tomer Chachamu):

* stage: Unreviewed => Accepted


Comment:

Thanks for the patch. If it's ready to review you can deassign the Trac
ticket. :)

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

Django

unread,
Nov 4, 2017, 10:28:36 AM11/4/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

For URL patterns that use `re_path()` is the route already available from
`ResolverMatch`? If not, I'm unsure why this attribute would only be set
for `path()`.

(By the way, there's no need to deassign the ticket to get it in the
review queue.)

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

Django

unread,
Nov 5, 2017, 11:20:20 AM11/5/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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
-------------------------------------+-------------------------------------

Comment (by Benjamin Wohlwend):

Replying to [comment:3 Tim Graham]:


> For URL patterns that use `re_path()` is the route already available
from `ResolverMatch`? If not, I'm unsure why this attribute would only be
set for `path()`.

`re_path()` uses `RegexPattern`, which doesn't have a route, but a regex.
Do you think the regex should be set in that case? That would simplify the
code a bit. Instead of `getattr(pattern._route)`, we could just use
`str(pattern)` (`__str__` prints `_route` for `RoutePattern` objects, and
`_regex` for `RegexPattern`).

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

Django

unread,
Nov 6, 2017, 9:33:12 AM11/6/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Yes, that's what I meant to suggest.

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

Django

unread,
Nov 6, 2017, 10:09:27 AM11/6/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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
-------------------------------------+-------------------------------------

Comment (by Benjamin Wohlwend):

OK. However, in that case I think the attribute on `ResolverMatch` should
be named differently, since AFAICT, "route" is specific to the new
simplified URLs from DEP 201. Maybe `ResolverMatch.pattern`?

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

Django

unread,
Nov 6, 2017, 1:07:52 PM11/6/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

The first argument of `re_path()` is also documented as `route` so I think
it's okay to use that.

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

Django

unread,
Nov 7, 2017, 1:32:23 PM11/7/17
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Benjamin
| Wohlwend
Type: New feature | Status: assigned
Component: Core (URLs) | Version: 2.0
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 Tim Graham):

* needs_better_patch: 0 => 1


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

Django

unread,
Aug 3, 2018, 9:10:42 AM8/3/18
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-----------------------------------+------------------------------------
Reporter: Benjamin Wohlwend | Owner: mes3yd

Type: New feature | Status: assigned
Component: Core (URLs) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by mes3yd):

* owner: Benjamin Wohlwend => mes3yd
* needs_better_patch: 1 => 0
* has_patch: 1 => 0
* version: 2.0 => master


Comment:

Working on patch + test + docs.

@tim Do I need to submit a new document for contribution or can you link
the one I submitted already to this [github
account](https://github.com/mes3yd/)? The old account will get closed as
soon as there's nothing pending on it anymore.

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

Django

unread,
Aug 3, 2018, 10:01:48 AM8/3/18
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Melvyn
| Sopacua

Type: New feature | Status: assigned
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

You don't need to submit another Contributor License Agreement. Those
agreements are linked to you, not to your GitHub account.

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

Django

unread,
Nov 17, 2018, 6:24:45 PM11/17/18
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Melvyn
| Sopacua
Type: New feature | Status: assigned
Component: Core (URLs) | 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 Tim Graham):

* needs_better_patch: 0 => 1

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/10657 PR] with comments for
improvement.

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

Django

unread,
Nov 19, 2018, 7:03:35 AM11/19/18
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Melvyn
| Sopacua
Type: New feature | Status: assigned
Component: Core (URLs) | 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 Xavier Fernandez):

* needs_better_patch: 1 => 0


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

Django

unread,
Dec 6, 2018, 6:22:50 PM12/6/18
to django-...@googlegroups.com
#28766: Add route information to ResolverMatch
-------------------------------------+-------------------------------------
Reporter: Benjamin Wohlwend | Owner: Melvyn
| Sopacua
Type: New feature | Status: closed

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"79c196cfb287893aadc6b0e74603ffde1512170e" 79c196cf]:
{{{
#!CommitTicketReference repository=""
revision="79c196cfb287893aadc6b0e74603ffde1512170e"
Fixed #28766 -- Added ResolverMatch.route.

Co-Authored-By: Xavier Fernandez <xavier.f...@polyconseil.fr>
}}}

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

Reply all
Reply to author
Forward
0 new messages