janrain dynamic hostname in url

67 Aufrufe
Direkt zur ersten ungelesenen Nachricht

rjmolesa

ungelesen,
19.05.2012, 13:32:4119.05.12
an web...@googlegroups.com
How can I get the host name that web2py is running on so that I can simply deploy a janrain enabled app without editing db.py each time

auth.settings.login_form = RPXAccount(request, 
api_key='...', 
domain='...', 
url = "http://" + application.hostname + "/%s/default/user/login" % request.application)

Anthony

ungelesen,
19.05.2012, 14:23:4919.05.12
an web...@googlegroups.com
Try

url = URL('default', 'user', args='login', host=True, scheme=True)

That will construct a URL including the current host and the current scheme (i.e., http or https).

More generally, the current host can be found in request.env.http_host, and the current scheme in request.env.wsgi_url_scheme (request.is_https also indicates whether the scheme is https or not). See http://web2py.com/examples/simple_examples/status for more details about the request and response objects.

Anthony

Jon Molesa

ungelesen,
19.05.2012, 14:31:1819.05.12
an web...@googlegroups.com
BOOM! Much thanks. I have changed it to read:

auth.settings.login_form = RPXAccount(request,
api_key='...',
domain='...',
url = URL('default', 'user', args='login', host=True, scheme=True) +
"/%s/default/user/login" % request.application)

and it's working!
--
Jon Molesa
rjmo...@gmail.com

Anthony

ungelesen,
19.05.2012, 18:17:3719.05.12
an web...@googlegroups.com
url = URL('default', 'user', args='login', host=True, scheme=True) +
"/%s/default/user/login" % request.application)

URL('default', 'user', args='login', host=True, scheme=True) alone will produce http://yourdomain.com/yourapp/default/user/login, so there should be no need to add "/%s/default/user/login" % request.application, which will result in http://yourdomain.com/yourapp/default/user/login/yourapp/default/user/login. That will still work (the second /yourapp/default/user/login will just be interpreted as a set of request.args and ignored by web2py), but no need for it.

Anthony

Jon Molesa

ungelesen,
19.05.2012, 20:52:4519.05.12
an web...@googlegroups.com
Thank you.
--
Jon Molesa
rjmo...@gmail.com
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten