web/views/basetemplates.py
branchtls-sprint
changeset 818 dc45e3cc487c
parent 811 c6ebabe9db91
child 820 fcc11122ffe7
equal deleted inserted replaced
817:12320ff8d6e4 818:dc45e3cc487c
   119         if view.add_to_breadcrumbs and not view.binary:
   119         if view.add_to_breadcrumbs and not view.binary:
   120             req.update_breadcrumbs()
   120             req.update_breadcrumbs()
   121         view.set_http_cache_headers()
   121         view.set_http_cache_headers()
   122         req.validate_cache()
   122         req.validate_cache()
   123         with_templates = self.with_templates(view)
   123         with_templates = self.with_templates(view)
   124         if not with_templates:
   124         if with_templates:
   125             view.set_request_content_type()
       
   126             self.set_stream(templatable=False)
       
   127         else:
       
   128             self.set_request_content_type()
   125             self.set_request_content_type()
   129             content_type = self.content_type
   126             content_type = self.content_type
   130             self.template_header(content_type, view)
   127             self.template_header(content_type, view)
       
   128         else:
       
   129             view.set_request_content_type()
       
   130             self.set_stream(templatable=False)
   131         self.template('page-content', view=view, rset=rset)
   131         self.template('page-content', view=view, rset=rset)
   132         if with_templates:
   132         if with_templates:
   133             self.template_footer(view)
   133             self.template_footer(view)
   134 
   134 
   135     def with_templates(self, view):
   135     def with_templates(self, view):
   207 
   207 
   208 class PageContentTemplate(TheMainTemplate):
   208 class PageContentTemplate(TheMainTemplate):
   209     id = 'page-content'
   209     id = 'page-content'
   210 
   210 
   211     def call(self, view=None, rset=None):
   211     def call(self, view=None, rset=None):
   212         self.req.set_header('x-cubicweb-css', 'a.css;b.css')
       
   213         if view is None:
   212         if view is None:
   214             view, rset = self._select_view_and_rset()
   213             view, rset = self._select_view_and_rset()
   215         with_templates = self.with_templates(view)
   214         with_templates = self.with_templates(view)
   216         w = self.w
   215         w = self.w
   217         if with_templates:
   216         if with_templates:
   227             self.nav_html = UStringIO()
   226             self.nav_html = UStringIO()
   228             self.pagination(self.req, self.rset, self.nav_html.write,
   227             self.pagination(self.req, self.rset, self.nav_html.write,
   229                             not (view and view.need_navigation))
   228                             not (view and view.need_navigation))
   230             w(_(self.nav_html.getvalue()))
   229             w(_(self.nav_html.getvalue()))
   231             w(u'<div id="contentmain">\n')
   230             w(u'<div id="contentmain">\n')
       
   231         else:
       
   232             self.set_stream(templatable=False)            
   232         if view.binary:
   233         if view.binary:
   233             # have to replace our unicode stream using view's binary stream
   234             # have to replace our unicode stream using view's binary stream
   234             view.dispatch()
   235             view.dispatch()
   235             assert self._stream, 'duh, template used as a sub-view ?? (%s)' % self._stream
   236             assert self._stream, 'duh, template used as a sub-view ?? (%s)' % self._stream
   236             self._stream = view._stream
   237             self._stream = view._stream