fix ui.main-template property handling tls-sprint
authorsylvain.thenault@logilab.fr
Fri, 20 Feb 2009 01:48:06 +0100
branchtls-sprint
changeset 882 75488a2a875e
parent 881 18e6c8db7bc5
child 883 44f1aba675de
fix ui.main-template property handling
web/application.py
web/views/basecontrollers.py
--- a/web/application.py	Fri Feb 20 01:47:43 2009 +0100
+++ b/web/application.py	Fri Feb 20 01:48:06 2009 +0100
@@ -385,7 +385,8 @@
                 req.data['excinfo'] = excinfo
             req.form['vid'] = 'error'
             errview = self.vreg.select_view('error', req, None)
-            content = self.vreg.main_template(req, 'main-template', view=errview)
+            template = self.main_template_id(req)
+            content = self.vreg.main_template(req, template, view=errview)
         except:
             content = self.vreg.main_template(req, 'error-template')
         raise StatusResponse(500, content)
@@ -397,11 +398,17 @@
         return self.vreg.main_template(req, 'loggedout')
     
     def notfound_content(self, req):
-        template = req.property_value('ui.main-template') or 'main-template'
         req.form['vid'] = '404'
         view = self.vreg.select_view('404', req, None)
+        template = self.main_template_id(req)
         return self.vreg.main_template(req, template, view=view)
 
+    def main_template_id(self, req):
+        template = req.property_value('ui.main-template')
+        if template not in self.vreg.registry('views') :
+            template = 'main-template'
+        return template
+        
 
 set_log_methods(CubicWebPublisher, LOGGER)
 set_log_methods(CookieSessionHandler, LOGGER)
--- a/web/views/basecontrollers.py	Fri Feb 20 01:47:43 2009 +0100
+++ b/web/views/basecontrollers.py	Fri Feb 20 01:48:06 2009 +0100
@@ -66,9 +66,7 @@
         view, rset = self._select_view_and_rset(rset)
         self.add_to_breadcrumbs(view)
         self.validate_cache(view)
-        template = self.req.property_value('ui.main-template')
-        if template not in self.vreg.registry('views') :
-            template = self.template
+        template = self.appli.main_template_id(self.req)
         return self.vreg.main_template(self.req, template, rset=rset, view=view)
 
     def _select_view_and_rset(self, rset):