etwist/server.py
changeset 4914 dcb055f32d9b
parent 4772 ae1b2a0c8e86
parent 4911 898c35be5873
child 4960 26b2468a1e73
--- a/etwist/server.py	Mon Mar 01 11:26:14 2010 +0100
+++ b/etwist/server.py	Tue Mar 16 16:32:36 2010 +0100
@@ -99,15 +99,11 @@
     def __init__(self, config, debug=None):
         self.debugmode = debug
         self.config = config
-        self.base_url = config['base-url'] or config.default_base_url()
-        if self.base_url[-1] != '/':
-            self.base_url += '/'
-        self.https_url = config['https-url']
-        if self.https_url and self.https_url[-1] != '/':
-            self.https_url += '/'
         # instantiate publisher here and not in init_publisher to get some
         # checks done before daemonization (eg versions consistency)
         self.appli = CubicWebPublisher(config, debug=self.debugmode)
+        self.base_url = config['base-url']
+        self.https_url = config['https-url']
         self.versioned_datadir = 'data%s' % config.instance_md5_version()
 
     def init_publisher(self):
@@ -250,21 +246,12 @@
                                  headers=req.headers_out or None)
         except ExplicitLogin:  # must be before AuthenticationError
             return self.request_auth(req)
-        except AuthenticationError:
-            if self.config['auth-mode'] == 'cookie':
-                # in cookie mode redirecting to the index view is enough :
-                # either anonymous connection is allowed and the page will
-                # be displayed or we'll be redirected to the login form
-                msg = req._('you have been logged out')
-                if req.https:
-                    req._base_url =  self.base_url
-                    req.https = False
-                url = req.build_url('view', vid='index', __message=msg)
-                return self.redirect(req, url)
-            else:
-                # in http we have to request auth to flush current http auth
-                # information
-                return self.request_auth(req, loggedout=True)
+        except AuthenticationError, ex:
+            if self.config['auth-mode'] == 'cookie' and getattr(ex, 'url', None):
+                return self.redirect(req, ex.url)
+            # in http we have to request auth to flush current http auth
+            # information
+            return self.request_auth(req, loggedout=True)
         except Redirect, ex:
             return self.redirect(req, ex.location)
         # request may be referenced by "onetime callback", so clear its entity