routes_out protocol

33 views
Skip to first unread message

LightOfMooN

unread,
Apr 11, 2011, 1:13:37 PM4/11/11
to web2py-users
Hello
I have some records in my routes.py

in routes_in:
(r'.*://$sub\.domain\.ru:.* /?', r'/myapp/company/index/$sub'),

in routes_out:
('/myapp/company/index/$sub', 'http://$sub.domain.ru'),

So, routes_in workds fine, but routes_out works only by http.
Is there a way to get protocol in routes_out?

Jonathan Lundell

unread,
Apr 11, 2011, 1:45:55 PM4/11/11
to web...@googlegroups.com

Do you mean the subdomain?

If the incoming request was for sub.domain.ru, then you want to return a URL that's relative to the scheme & domain, and let the browser fill them in.

If the request was for sub.domain.ru, and you're generating a URL for other.domain.ru, then you've got no choice but to specify the URL explicitly.

It's probably best not to use URL() for the cross-domain case, I think. The parametric (new) router assumes that the URL being generated is in the same domain as the current request. I can see how it might be enhanced to support cross-domain URLs, but it's not trivial, and it doesn't happen now.

LightOfMooN

unread,
Apr 11, 2011, 10:43:43 PM4/11/11
to web2py-users
The problem is because urls is relative, not absolute.

My problem is:
If I have https and I'm in sub1.domain.ru, I can't make url
https://sub2.domain.ru, because I can't catch protocol in routes_out,
like ('$protocol*://domain\.ru:.* /myapp/company/index/$sub',
'$protocol*://$sub.domain.ru'),

Dan

unread,
May 3, 2011, 4:37:47 PM5/3/11
to web2py-users
Hi, did you find any solution to your problem?

I have the same problem. The Url function should build a link over ssl
(https) if the url contains the controller "user". e.g. /myapp/user/
login or /myapp/user/register



On Apr 12, 4:43 am, LightOfMooN <vladsale...@yandex.ru> wrote:
> The problem is because urls is relative, not absolute.
>
> My problem is:
> If I have https and I'm in sub1.domain.ru, I can't make urlhttps://sub2.domain.ru, because I can't catch protocol inroutes_out,
> like ('$protocol*://domain\.ru:.* /myapp/company/index/$sub',
> '$protocol*://$sub.domain.ru'),
>
> On 11 апр, 23:45, Jonathan Lundell <jlund...@pobox.com> wrote:
>
>
>
> > On Apr 11, 2011, at 10:13 AM, LightOfMooN wrote:
>
> > > Hello
> > > I have some records in my routes.py
>
> > > in routes_in:
> > >    (r'.*://$sub\.domain\.ru:.* /?', r'/myapp/company/index/$sub'),
>
> > > inroutes_out:
> > >    ('/myapp/company/index/$sub', 'http://$sub.domain.ru'),
>
> > > So, routes_in workds fine, butroutes_outworks only by http.

LightOfMooN

unread,
May 4, 2011, 9:09:03 AM5/4/11
to web2py-users
No, i didn't
Reply all
Reply to author
Forward
0 new messages