web/application.py
changeset 2293 7ded2a1416e4
parent 2235 d5987f75c97c
parent 2272 f27a3a75be0d
child 2476 1294a6bdf3bf
equal deleted inserted replaced
2235:d5987f75c97c 2293:7ded2a1416e4
    19     ValidationError, Unauthorized, AuthenticationError, NoSelectableObject,
    19     ValidationError, Unauthorized, AuthenticationError, NoSelectableObject,
    20     RepositoryError)
    20     RepositoryError)
    21 from cubicweb.web import LOGGER, component
    21 from cubicweb.web import LOGGER, component
    22 from cubicweb.web import (
    22 from cubicweb.web import (
    23     StatusResponse, DirectResponse, Redirect, NotFound,
    23     StatusResponse, DirectResponse, Redirect, NotFound,
    24     RemoteCallFailed, ExplicitLogin, InvalidSession)
    24     RemoteCallFailed, ExplicitLogin, InvalidSession, RequestError)
    25 from cubicweb.web.component import Component
       
    26 
    25 
    27 # make session manager available through a global variable so the debug view can
    26 # make session manager available through a global variable so the debug view can
    28 # print information about web session
    27 # print information about web session
    29 SESSION_MANAGER = None
    28 SESSION_MANAGER = None
    30 
    29 
   338                     raise
   337                     raise
   339             except (AuthenticationError, NotFound, RemoteCallFailed):
   338             except (AuthenticationError, NotFound, RemoteCallFailed):
   340                 raise
   339                 raise
   341             except ValidationError, ex:
   340             except ValidationError, ex:
   342                 self.validation_error_handler(req, ex)
   341                 self.validation_error_handler(req, ex)
   343             except (Unauthorized, BadRQLQuery), ex:
   342             except (Unauthorized, BadRQLQuery, RequestError), ex:
   344                 self.error_handler(req, ex, tb=False)
   343                 self.error_handler(req, ex, tb=False)
   345             except Exception, ex:
   344             except Exception, ex:
   346                 self.error_handler(req, ex, tb=True)
   345                 self.error_handler(req, ex, tb=True)
   347         finally:
   346         finally:
   348             if req.cnx is not None:
   347             if req.cnx is not None:
   394         view = self.vreg.select('views', '404', req)
   393         view = self.vreg.select('views', '404', req)
   395         template = self.main_template_id(req)
   394         template = self.main_template_id(req)
   396         return self.vreg.main_template(req, template, view=view)
   395         return self.vreg.main_template(req, template, view=view)
   397 
   396 
   398     def main_template_id(self, req):
   397     def main_template_id(self, req):
   399         template = req.property_value('ui.main-template')
   398         template = req.form.get('__template', req.property_value('ui.main-template'))
   400         if template not in self.vreg.registry('views') :
   399         if template not in self.vreg.registry('views'):
   401             template = 'main-template'
   400             template = 'main-template'
   402         return template
   401         return template
   403 
   402 
   404 
   403 
   405 set_log_methods(CubicWebPublisher, LOGGER)
   404 set_log_methods(CubicWebPublisher, LOGGER)