[jsoncontroller] reorganize _html_exec (used by replacePageChunk) to output required css and js scripts tls-sprint
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 16 Feb 2009 20:42:30 +0100
branchtls-sprint
changeset 643 616191014b8b
parent 642 2cf7b79d8e77
child 644 5e5b296a657e
[jsoncontroller] reorganize _html_exec (used by replacePageChunk) to output required css and js scripts
common/utils.py
web/views/basecontrollers.py
--- a/common/utils.py	Mon Feb 16 20:40:12 2009 +0100
+++ b/common/utils.py	Mon Feb 16 20:42:30 2009 +0100
@@ -177,7 +177,7 @@
             self.post_inlined_scripts.append(self.js_unload_code)
             self.pagedata_unload = True
 
-    def getvalue(self):
+    def getvalue(self, skiphead=False):
         """reimplement getvalue to provide a consistent (and somewhat browser
         optimzed cf. http://stevesouders.com/cuzillion) order in external
         resources declaration
@@ -209,7 +209,10 @@
             w(u'<script type="text/javascript">\n')
             w(u'\n\n'.join(self.post_inlined_scripts))
             w(u'\n</script>\n')
-        return u'<head>\n%s</head>\n' % super(HTMLHead, self).getvalue()
+        header = super(HTMLHead, self).getvalue()
+        if skiphead:
+            return header
+        return u'<head>\n%s</head>\n' % header
         
 
 class HTMLStream(object):
--- a/web/views/basecontrollers.py	Mon Feb 16 20:40:12 2009 +0100
+++ b/web/views/basecontrollers.py	Mon Feb 16 20:42:30 2009 +0100
@@ -211,14 +211,14 @@
             self.req.set_content_type(content_type)
             return xmlize(data)
         return data
-
+    
     def html_exec(self, rset=None):
-        """html mode: execute query and return the view as HTML"""
+        # XXX try to use the page-content template
         req = self.req
         rql = req.form.get('rql')
         if rset is None and rql:
             rset = self._exec(rql)
-            
+        
         vid = req.form.get('vid') or vid_from_rset(req, rset, self.schema)
         try:
             view = self.vreg.select_view(vid, req, rset)
@@ -239,6 +239,10 @@
             if divid == 'pageContent':
                 stream.write(u'<div id="contentmain">')
         view.dispatch()
+        extresources = req.html_headers.getvalue(skiphead=True)
+        stream.write(u'<div class="ajaxHtmlHead">\n') # XXX use a widget ?
+        stream.write(extresources)
+        stream.write(u'</div>\n')
         if req.form.get('paginate') and divid == 'pageContent':
             stream.write(u'</div></div>')
         source = stream.getvalue()