Okay, I get it now, routes_app does not select the application, only where 
to get the substitute routes.py.  The book is right with hindsight, but did 
not lead me to the right understanding. Maybe it should be clearer that it 
only controls which routes.py is used. 

The phrase " This is enabled by configuring routes_app in the base 
routes.py to determine from an incoming URL the name of the application to 
be selected ". Does imply a bit more than this. Pattern based routing is 
confusing enough already.

Could you now explain the following.

If I have a URL

127.0.0.1:8002/gallery

This selects my gallery app.

If in routes.py I put

routes_in = (('/gallery','/welcome'),)

It does now route

127.0.0.1:8002/gallery to the welcome app.

However if I change the routes_in to

routes_in = (('2/gallery','2/welcome'),)

it no longer routes

127.0.0.1:8002/gallery to the welcome app, but leaves it as the gallery 
app, so routes_in is no longer working.

Why is this?
Thanks







On Wednesday, 29 August 2012 12:53:02 UTC+1, Anthony wrote:
>
> routes_app is used to tell the routing system which applications have 
> their own application specific routes.py (in the application folder rather 
> than the web2py root folder). I think you want to use routes_in (probably 
> with a matching routes_out) instead. See 
> http://web2py.com/books/default/chapter/29/4#Pattern-based-system.
>
> Anthony
> On Wednesday, August 29, 2012 7:44:13 AM UTC-4, peter wrote:
>>
>> I will try this post again, unfortunately I did not have a copy
>>
>> I tried this example routes.py
>>
>> #!/usr/bin/python
>> # -*- coding: utf-8 -*-
>> routes_app = ((r'/(?P<app>welcome|admin|app)\b.*', r'\g<app>'),
>>               (r'(.*)', r'myapp'),
>>               (r'/?(.*)', r'myapp'))
>>
>> I restarted the server
>> web2py uses port 8002, on a windows 7 machine.
>>
>> As I understand the example it should allow apps welcome admin and app, 
>> but for other apps it should revert to 'myapp'.
>>
>> 127.0.0.1:8002/welcome starts the welcome app as it should
>>
>> 127.0.0.1:8002/gallery starts the gallery app, so the routing does not 
>> appear to be working.
>> 127.0.0.1:8002 starts the welcome app, so the routing does not appear to 
>> be working.
>>
>> Does anyone have any ideas why it is not working. If I put a syntax error 
>> in then this gets flagged up, so it is being loaded.
>>
>> I need to use pattern based routing within an app, so I need to get on 
>> top of this.
>>
>> I would like, within routes_app to be able to route according to domain 
>> name.
>>
>> So what would routes_app look like to route
>>
>> 127.0.0.1:8002 to welcome, and
>>
>> localhost:8002 to admin
>>
>> Thanks
>>
>> Peter
>>
>>
>>
>>
>>

-- 



Reply via email to