web/request.py
changeset 8309 48ef505aa9f9
parent 8271 3bd9b317b1d8
child 8312 6c2119509fac
--- a/web/request.py	Thu Mar 15 17:30:28 2012 +0100
+++ b/web/request.py	Mon Feb 27 15:24:14 2012 +0100
@@ -86,7 +86,7 @@
     """
     ajax_request = False # to be set to True by ajax controllers
 
-    def __init__(self, vreg, https, form=None):
+    def __init__(self, vreg, https=False, form=None):
         """
         :vreg: Vregistry,
         :https: boolean, s this a https request
@@ -144,6 +144,22 @@
         self.ajax_request = value
     json_request = property(_get_json_request, _set_json_request)
 
+    def base_url(self, secure=None):
+        """return the root url of the instance
+
+        secure = False -> base-url
+        secure = None  -> https-url if req.https
+        secure = True  -> https if it exist
+        """
+        if secure is None:
+            secure = self.https
+        base_url = None
+        if secure:
+            base_url = self.vreg.config.get('https-url')
+        if base_url is None:
+            base_url = super(CubicWebRequestBase, self).base_url()
+        return base_url
+
     @property
     def authmode(self):
         """Authentification mode of the instance