Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upurl dispatch: regexes with braces not currently accounted for and are not matched properly #123
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
mcdonc
Feb 9, 2011
Member
- URL pattern markers used in URL dispatch are permitted to specify a custom
regex. For example, the pattern/{foo:\d+}means to match/12345
(foo==12345 in the match dictionary) but not/abc. However, custom
regexes in a pattern marker which used squiggly brackets did not work. For
example,/{foo:\d{4}}would fail to match/1234and
/{foo:\d{1,2}}would fail to match/1or/11. One level of
inner squiggly brackets is now recognized so that the prior two patterns
given as examples now work. See also
https://github.com/Pylons/pyramid/issues/#issue/123.
Closed by 9595236
Closed by 9595236 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
mcdonc
Feb 17, 2011
Member
I have to reopen this, because the regex we used in commit #9594236 doesnt work on Jython. Here's the comment I put into the source code:
# The regex named ``torturous_route_re`` below allows us to support at least
# one level of "inner" squigglies inside the expr of a {name:expr} pattern;
# for example, {foo:\d{4}}. Thanks to Zart for the regex help.
# ``torturous_route_re`` is meant to be a replacement for the regex named
# ``route_re`` (which is just (\{[a-zA-Z][^\}]*\})) because ``route_re``
# chokes when it encounters inner squigglies. However
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507 means that the
# torturous regex doesn't work on Jython (recursion error), so we've disabled
# it in favor of ``route_re`` for now. If somebody can make something that
# will work on Jython but also match inner squigglies, it'd be useful.
# torturous_route_re = re.compile(r'(\{[a-zA-Z](?:\{[^\}]*\}|[^\{\}]*)*\})')
route_re = re.compile(r'(\{[a-zA-Z][^\}]*\})')
|
I have to reopen this, because the regex we used in commit #9594236 doesnt work on Jython. Here's the comment I put into the source code:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
mcdonc
closed this
Apr 19, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nek4life commentedFeb 9, 2011
Example:
does not match /2002/ for instance.
Untested but ranges may not be accounted for either {m, n}