What's the proper way to use URL helper from one app to another (having routed one domain per app)?

22 views
Skip to first unread message

Lisandro

unread,
Apr 20, 2015, 12:46:12 PM4/20/15
to web...@googlegroups.com
I have one instance of web2py installed on production, with several apps. 
Each app is served by a specific domain. This is acomplished usign parameter-based routing system, this what I have in routes.py file:

# -*- coding: utf-8 -*-
routers
= dict(BASE = dict(\
    default_controller
= 'default', \
    default_function
= 'index', \
    domains
= {\
     
'site1.com':'app1', \
     
'site2.com':'app2', \
     
'site3.com':'app3', \
   
}\
))

Now I need to use URL() helper to generate links from one application to another. 
Considering the previous configuration, is it ok to generate links in the following way?

From app1, generate a link to go to the site2 homepage:
URL('default', 'index', host='site2.com')

From app2, generate a link to go to site3 contact page:
URL('default', 'contact', host='site3.com')

Is that the correct approach? Should I include the "application" parameter when using URL() helper in this case? 
Notice that I'm not specifying the "application" parameter, because it's given by the routes.py configuration. Also, if I do, it will be visible on the url generated, and I don't want the application to be visible on the url. So, is it ok to do it that way? Thanks in advance.

Richard Vézina

unread,
Apr 20, 2015, 1:39:14 PM4/20/15
to web2py-users
I guess you will need scheme=True...

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages