I do not know what docs you are talking about here Jonathan. If the book, 
then it is very brief on this matter. The example

"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:

1.
2.
3.
4.

routes_in = (
 ('140\.191\.\d+\.\d+:https://www.web2py.com:POST /(?P<any>.*)\.php',
  '/test/default/index?vars=\g<any>'),
)

"
Seems to suggest it is a string albeit with a gap after 'POST'. Is there 
any way of looking at the URL representation that goes into routes_in? It 
is hard working in the dark

I tried
routes_in = (('localhost(.*)/gallery','/welcome'),)

and this fails to map 
localhost:8002/gallery to welcome.

>From the example in the book one would have thought it ought to work.

Let me ask the second part of my initial post again, slightly modified:

I would like, within routes_in to be able to route according to domain name.

 So what would routes_in look like to route 

127.0.0.1:8002 to welcome, and

 localhost:8002 to admin
Thanks
Peter


On Wednesday, 29 August 2012 14:59:36 UTC+1, Jonathan Lundell wrote:
>
> On 29 Aug 2012, at 6:46 AM, peter <peterchu...@gmail.com <javascript:>> 
> wrote:
>
> 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?
>
>
> If you're trying to match the 2 from the port number, that's not going to 
> work. The incoming URL isn't presented as a single string, but is instead 
> broken up into components. I don't have the syntax at hand, but if you 
> review the docs with that in mind you'll probably figure it out. Or someone 
> else will chime in with the right pattern.
>

-- 



Reply via email to