I could not find a way to automatically create urls with scheme and host, so I aliased URL:
URL_WITHOUT_HOST = URL
def URL(a=None,c=None,f=None,r=None,args=[],vars={},host=None,scheme=None):
path = URL_WITHOUT_HOST(a=a,c=c,f=f,r=r,args=args,vars=vars)
if host or scheme:
if not isinstance(host,str): host = r.env.http_host
if not isinstance(scheme,str): scheme = r.env.wsgi_url_scheme
return '%s://%s%s' % (scheme,host,path)
return path
more versatile:
a=URL(r=request,args=[0],vars={'a':1,'b':2})
b=URL(r=request,host=True,args=[0],vars={'a':1,'b':2})
c=URL(r=request,scheme='https',args=[0],vars={'a':1,'b':2})
d=URL(r=request,scheme='https',host='www.google.com',args=[0],vars={'a':1,'b':2})
output:
a: /init/default/index/0?a=1&b=2
b: http://localhost:8080/init/default/index/0?a=1&b=2
c: https://localhost:8080/init/default/index/0?a=1&b=2
d: https://www.google.com/init/default/index/0?a=1&b=2