Closed GoogleCodeExporter closed 8 years ago
I'm not 100% sure of Rodrigo's intentions here but it seems Route templates can
only contain regular expression in regex components (i.e. <>).
Why are you using a route here anyway?
Original comment by bquin...@google.com
on 7 Dec 2011 at 3:37
Brian is correct.
If you use Route, all regular expression must be enclosed by <>. In the
example: webapp.Route(r'/thanks<:/?>', ThanksHandler, 'thanks'). It may not
make much sense because you don't want to capture the slash, but it'll capture
it. The alternative is to use a webapp-like tuple instead of a Route instance:
(r'/thanks/?', ThanksHandler), but then URLs can't be built.
The purpose of the <> syntax is to set placeholders to build URLs. It doesn't
use standard regexp named groups because it would be a lot complex to parse
(avoiding nested groups and several edge cases; see Django which fights this
since 2005).
Several projects adopt a similar <> approach or variants (Pyramid in Python
land and I saw it in Java and Ruby projects too) because of how tricky is to
reverse regexps.
Original comment by rodrigo.moraes
on 7 Dec 2011 at 11:53
Sorry, my bad, and thanks for the explanation. I had not realized that regex
expressions are only allowed inside <>. Maybe just me, but this constraint was
not clear from the description at
http://webapp-improved.appspot.com/guide/routing.html#guide-routing-the-regex-te
mplate.
The reason for using a route is uri building. I used a simplified example
above, so maybe uri building might not seem very appropriate. Now that I
understand correctly I'll keep playing with it.
Original comment by ro...@tawacentral.net
on 7 Dec 2011 at 1:17
Ok, fair enough. I'll try to make it more clear in the docs.
Original comment by rodrigo.moraes
on 7 Dec 2011 at 4:12
Oops. I pointed to issue 36 in the commit. It should be more clear now.
http://code.google.com/p/webapp-improved/source/detail?r=58cfeb9c718dfb8bf916a96
fcee719bb92aeaa2e
Original comment by rodrigo.moraes
on 7 Dec 2011 at 4:13
Original issue reported on code.google.com by
ro...@tawacentral.net
on 6 Dec 2011 at 2:29