Thanks Jonathan. I wish I had known about rewrite logging a couple of days
ago. Could I suggest that mention is made of this in the section of the
book on rewriting URLs. It could save people a lot of time.
Could I also suggest that
routes_app=[('.*://mydomain:\w* /$anything','myapp'),
is given in the book as an example of mapping a domain to an app. I do not
think that anyone would get to the above from the docs without a lot of
trial and error.
Thanks
Peter
On Thursday, 30 August 2012 15:39:51 UTC+1, Jonathan Lundell wrote:
>
> On 30 Aug 2012, at 1:59 AM, peter <[email protected] <javascript:>>
> 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')]
--