Re: [Django] #7571: named groups in the regexes of include() urls break reverse()

2 views
Skip to first unread message

Django

unread,
Sep 11, 2011, 5:20:49 PM9/11/11
to django-...@googlegroups.com
#7571: named groups in the regexes of include() urls break reverse()
------------------------------------+------------------------------
Reporter: trevor | Owner: nobody
Type: Bug | Status: reopened
Milestone: | Component: Core (Other)
Version: SVN | 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 Alex):

* ui_ux: => 0
* easy: => 0
* stage: Design decision needed => Accepted


Comment:

trevor's comment demonstrates a genuine bug.

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

Django

unread,
Mar 7, 2013, 7:27:55 AM3/7/13
to django-...@googlegroups.com
#7571: named groups in the regexes of include() urls break reverse()
------------------------------+------------------------------------

Reporter: trevor | Owner: nobody
Type: Bug | Status: reopened
Component: Core (Other) | 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 micfan):

it seems okay now:
{{{
reverse('test', args=['foo', 'bar', 'bat'])
# gives:
'/foo/bar/bat/'
}}}

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

Django

unread,
Feb 27, 2014, 11:26:44 AM2/27/14
to django-...@googlegroups.com
#7571: named groups in the regexes of include() urls break reverse()
------------------------------+------------------------------------
Reporter: trevor | Owner: afuna
Type: Bug | Status: assigned

Component: Core (Other) | 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 afuna):

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


Comment:

So, it looks like this is actually two things.

The original issue as described has been fixed. This is a case of outer
regex + included regex, both using named groups. There's a test case in
urlpatterns_reverse/tests.py that matches and confirms:

`('inner-extra', '/outer/42/extra/inner/', ['42', 'inner'], {}),` in
`test_data`

where the relevant url patterns are: `url(r'^outer/(?P<outer>\d+)/',
include('urlpatterns_reverse.included_urls')),` and
`url(r'^extra/(?P<extra>\w+)/$', empty_view, name="inner-extra"),`

comment:6 is a different thing and that one is still broken. That is a
case of both the outer and inner regex using positional parameters, and
the positions overlapping when the inner regex is appended to the outer
regex. So for example:

outer regex: `outer/(\d+)/`
inner regx: `inner/(\d+)/`
arguments: 123, 456

resolves to /outer/123/inner/123/

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

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

Django

unread,
Mar 4, 2014, 6:37:59 PM3/4/14
to django-...@googlegroups.com
#7571: named groups in the regexes of include() urls break reverse()
------------------------------+------------------------------------
Reporter: trevor | Owner: afuna
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

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 Baptiste Mispelon <bmispelon@…>):

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


Comment:

In [changeset:"5d568bcfa66916e3de61e0090c724c899debd981"]:
{{{
#!CommitTicketReference repository=""
revision="5d568bcfa66916e3de61e0090c724c899debd981"
Fixed #7571 -- Fixed parameter matching in include()'d urlpattern

Fixed URL resolving in the case where an outer regex includes an inner
regex and both regexes use positional parameters instead of named
groups, causing the outer regex's parameters to override the inner
regex's.

Modified the regex url resolver so that it will concatenates and then
normalizes, instead of normalizing and then concatenating.
}}}

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

Reply all
Reply to author
Forward
0 new messages