ok for the book, but routes.py is ok.
if you notice, there's the r in front of the string.... that r means
"string literal", as in "literally this string", so \n, \t, etc don't get
interpreted and quoting isn't necessary (because it gets interpreted as a
byte string and not a string)
Actually, while working with regexes, it's quite handy to have r at
hand....as you noticed the syntax gets increasingly crispy if you choose to
not use string literals.
This is explained in detail on http://docs.python.org/2/library/re.html
On Thursday, August 8, 2013 12:09:50 AM UTC+2, LightDot wrote:
>
> Best thing to do would be to open an issue on Google code and either
> attach a patch or make a pull request on Github.
>
> Forum posts can get overlooked and/or forgotten...
>
> Regards,
> Ales
>
> On Wednesday, August 7, 2013 3:17:01 PM UTC+2, mweissen wrote:
>>
>> About routes.py
>>
>> I have tried to use routes.py. After some hours I have found errors in
>> the book and in routes.example.py:
>>
>> ----------------------------------------------------------------------
>>
>> In the book, chapter "URL rewrite":
>>
>> The general syntax for routes is more complex than the simple examples we
>> have seen so far. Here is a more general and representative example:
>>
>> routes_in = (
>> ('140.191.\d+.\d+:https?://www.web2py.com:post /(?P<any>.*).php',
>> '/test/default/index?vars=\g<any>'),
>> )
>>
>> It maps http or https POST requests (note lower case "post") to host
>> www.web2py.com from a remote IP matching the regular expression
>>
>> '140.191.\d+.\d+'
>>
>> The first part is a regular expression. I think, it should read:
>>
>> The general syntax for routes is more complex than the simple examples we
>> have seen so far. Here is a more general and representative example:
>> routes_in = ( ('140\.191\.\d+\.\d+:https?://www\.web2py\.com:post
>> /(?P<any>.*).php', '/test/default/index?vars=\g<any>'), )
>>
>> It maps http or https POST requests (note lower case "post") to host
>> www.web2py.com from a remote IP matching the regular expression
>> '140\.191\.\d+\.\d+'
>>
>> ----------------------------------------------------------------------
>>
>> Changes in routes.examples.py:
>>
>> routes_in = (
>> # do not reroute admin unless you want to disable it
>> (BASE + '/admin', '/admin/default/index'),
>> (BASE + '/admin/$anything', '/admin/$anything'),
>> # do not reroute appadmin unless you want to disable it
>> (BASE + '/$app/appadmin', '/$app/appadmin/index'),
>> (BASE + '/$app/appadmin/$anything', '/$app/appadmin/$anything'),
>> # do not reroute static files
>> (BASE + '/$app/static/$anything', '/$app/static/$anything'),
>> # reroute favicon and robots, use exable for lack of better choice
>> ('/favicon.ico', '/examples/static/favicon.ico'),
>> ('/robots.txt', '/examples/static/robots.txt'),
>> # do other stuff
>> ((r'.*http://otherdomain.com.* (?P<any>.*)', r'/app/ctr\g<any>')),
>> # remove the BASE prefix
>> (BASE + '/$anything', '/$anything'),
>> )
>>
>> Change to:
>>
>> routes_in = (
>> # do not reroute admin unless you want to disable it
>> (BASE + '/admin', '/admin/default/index'),
>> (BASE + '/admin/$anything', '/admin/$anything'),
>> # do not reroute appadmin unless you want to disable it
>> (BASE + '/$app/appadmin', '/$app/appadmin/index'),
>> (BASE + '/$app/appadmin/$anything', '/$app/appadmin/$anything'),
>> # do not reroute static files
>> (BASE + '/$app/static/$anything', '/$app/static/$anything'),
>> # reroute favicon and robots, use exable for lack of better choice
>> ('/favicon.ico', '/examples/static/favicon.ico'),
>> ('/robots.txt', '/examples/static/robots.txt'),
>> # do other stuff
>> (r'.*http://otherdomain\.com.* (?P<any>.*)', r'/app/ctr\g<any>'),
>> # remove the BASE prefix
>> (BASE + '/$anything', '/$anything'),
>> )
>>
>> ----------------------------------------------------------------------
>>
>>
>> And
>>
>> routes_out = (
>> # do not reroute admin unless you want to disable it
>> ('/admin/$anything', BASE + '/admin/$anything'),
>> # do not reroute appadmin unless you want to disable it
>> ('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'),
>> # do not reroute static files
>> ('/$app/static/$anything', BASE + '/$app/static/$anything'),
>> # do other stuff
>> (r'.*http://otherdomain.com.* /app/ctr(?P<any>.*)', r'\g<any>'),
>> (r'/app(?P<any>.*)', r'\g<any>'),
>> # restore the BASE prefix
>> ('/$anything', BASE + '/$anything'),
>> )
>>
>> Change to:
>>
>> routes_out = (
>> # do not reroute admin unless you want to disable it
>> ('/admin/$anything', BASE + '/admin/$anything'),
>> # do not reroute appadmin unless you want to disable it
>> ('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'),
>> # do not reroute static files
>> ('/$app/static/$anything', BASE + '/$app/static/$anything'),
>> # do other stuff
>> (r'.*http://otherdomain\.com.* /app/ctr(?P<any>.*)', r'\g<any>'),
>> (r'/app(?P<any>.*)', r'\g<any>'),
>> # restore the BASE prefix
>> ('/$anything', BASE + '/$anything'),
>> )
>>
>> Hope, it could help...
>> Regards, Martin
>>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.