Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#9123 closed Uncategorized (invalid)

URL Resolver tag chokes with verbose regex in the urlconf

Reported by: Jeff Anderson Owned by: nobody
Component: Template system Version: 1.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Any project that uses python verbose regular expressions in its urlconf causes the {% url %} tag to crash. I believe that the culprit is likely r8760, though I haven't tested that theory. The {% url %} tag throws a TemplateSyntaxError with Exception Value: Caught an exception while rendering: Non-reversible reg-exp portion: '(?x'

If r8760 really was the culprit, then it isn't 100% backwards compatible.

Change History (3)

comment:1 by Malcolm Tredinnick, 16 years ago

Resolution: invalid
Status: newclosed

Backwards-compatible doesn't mean that it necessarily continues to work for things it wasn't originally designed for that just happened to work by accident. It's unfortunate that there were some of these accidental cases that people were relying on, but there's nothing that can be done about that.

The reverse resolver does explicitly exclude (?x) and raises an appropriately descriptive error message. It initially appeared to complicate the code too much to handle that, but if you want to write a patch that isn't too intrusive, it would certainly be nice to include it.

Closing this for now, since the reverse resolver works as expected. If you do write a patch, please, by all means, open a new ticket and attach it.

comment:2 by Jeff Anderson, 16 years ago

The problem isn't necessarily that the reverse mapper can't generate a reverse for a verbose regex, as much as it breaks *all* url tags.

When I went to the admin main page, it'd die and throw the error from the admin template. This made debugging the actual underlying issue very cryptic and strange.

I was playing with the old URL resolver, and it appears that it can't exactly "figure out" a url based on a verbose regex, but it wouldn't choke and die if there happened to be a verbose regex in the urlconf.

I'll try to at least work out a different way to "die better" and open a new ticket with that patch. It really made quite the head scratcher for me and a couple people that had no idea why in the world the admin app appeared to not be working once upgrading to 1.0.

comment:3 by Greg Brown, 12 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

As of django 1.3, this is still an issue. There is no reason why one non-reversible url should break the entire url tag, and no mention in the docs that it does this.

Note: See TracTickets for help on using tickets.
Back to Top