On 30 Aug 2012, at 1:59 AM, peter <peterchutchin...@gmail.com> wrote:
> I got inside gluon. The conversion is done within regex_uri
> 
> I have found that 
> 
> http://127.0.0.1:8002/gallery
> becomes
> 127.0.0.1:http://127.0.0.1:get /gallery
> 
> just before the conversion
> 
> http://localhost:8002/gallery
> becomes
> 127.0.0.1:http://localhost:get /gallery
> 
> So Massimo was almost right the problem was putiing the get and post in upper 
> case
> 
> routes_in = [('127\.0\.0\.1:http://.*?:(get|post) /$anything','/welcome')]
> works
> The answer to my challenge to get URLs with localhost to route to the admin 
> app and URLs with 127.0.0.1 to route to the  welcome app
> 
> routes_in = [('.*://localhost:(get|post) /$anything','/admin'),
>                            ('.*://127\.0\.0\.1:(get|post) 
> /$anything','/welcome')]
> 
> So presumably to map mydomain to myapp would be
> 
> routes_in = [('.*://mydomain:(get|post) /myapp/$anything','/myapp/$anything'),
>                   ('.*://mydomain:(get|post) /$anything','/myapp/$anything')]
> 
> or if using routes_app
> 
> routes_app=[('.*://mydomain:(get|post) /$anything','myapp'),
> 

Unless you really want to restrict routing to get & post (excluding, say, 
head), why not match on \w* instead of (get|post)?

routes_in = [('.*://localhost:\w* /$anything','/admin/$anything'),
             ('.*://127\.0\.0\.1:\w* /$anything','/welcome/$anything')]

For future reference, you can turn on rewrite logging to see what's going on: 
the router will log the regex strings that it's using, and the result of the 
rewrite.

Notice that this routes_in causes a problem (I think) in welcome/appadmin when 
it generates URLs with URL('admin', ...). These will come in from 127.0.0.1, 
and be routed to welcome instead of admin. So:

routes_in = [('.*://localhost:\w* /$anything','/admin/$anything'),
             ('.*://127\.0\.0\.1:\w* /admin/$anything','/admin/$anything'),
             ('.*://127\.0\.0\.1:\w* /$anything','/welcome/$anything')]

-- 



Reply via email to