etwist/server.py
branchstable
changeset 4911 898c35be5873
parent 4909 a13c1d1ecc5b
child 4914 dcb055f32d9b
equal deleted inserted replaced
4910:f40fddaa79ad 4911:898c35be5873
   244             result = self.appli.notfound_content(req)
   244             result = self.appli.notfound_content(req)
   245             return http.Response(stream=result, code=responsecode.NOT_FOUND,
   245             return http.Response(stream=result, code=responsecode.NOT_FOUND,
   246                                  headers=req.headers_out or None)
   246                                  headers=req.headers_out or None)
   247         except ExplicitLogin:  # must be before AuthenticationError
   247         except ExplicitLogin:  # must be before AuthenticationError
   248             return self.request_auth(req)
   248             return self.request_auth(req)
   249         except AuthenticationError:
   249         except AuthenticationError, ex:
   250             if self.config['auth-mode'] == 'cookie':
   250             if self.config['auth-mode'] == 'cookie' and getattr(ex, 'url', None):
   251                 # in cookie mode redirecting to the index view is enough :
   251                 return self.redirect(req, ex.url)
   252                 # either anonymous connection is allowed and the page will
   252             # in http we have to request auth to flush current http auth
   253                 # be displayed or we'll be redirected to the login form
   253             # information
   254                 msg = req._('you have been logged out')
   254             return self.request_auth(req, loggedout=True)
   255                 if req.https:
       
   256                     req._base_url =  self.base_url
       
   257                     req.https = False
       
   258                 url = req.build_url('view', vid='index', __message=msg)
       
   259                 return self.redirect(req, url)
       
   260             else:
       
   261                 # in http we have to request auth to flush current http auth
       
   262                 # information
       
   263                 return self.request_auth(req, loggedout=True)
       
   264         except Redirect, ex:
   255         except Redirect, ex:
   265             return self.redirect(req, ex.location)
   256             return self.redirect(req, ex.location)
   266         # request may be referenced by "onetime callback", so clear its entity
   257         # request may be referenced by "onetime callback", so clear its entity
   267         # cache to avoid memory usage
   258         # cache to avoid memory usage
   268         req.drop_entity_cache()
   259         req.drop_entity_cache()