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.


Reply via email to