common/utils.py
branchtls-sprint
changeset 643 616191014b8b
parent 28 9b7067bfaa15
equal deleted inserted replaced
642:2cf7b79d8e77 643:616191014b8b
   175         """registers onunload callback to clean page data on server"""
   175         """registers onunload callback to clean page data on server"""
   176         if not self.pagedata_unload:
   176         if not self.pagedata_unload:
   177             self.post_inlined_scripts.append(self.js_unload_code)
   177             self.post_inlined_scripts.append(self.js_unload_code)
   178             self.pagedata_unload = True
   178             self.pagedata_unload = True
   179 
   179 
   180     def getvalue(self):
   180     def getvalue(self, skiphead=False):
   181         """reimplement getvalue to provide a consistent (and somewhat browser
   181         """reimplement getvalue to provide a consistent (and somewhat browser
   182         optimzed cf. http://stevesouders.com/cuzillion) order in external
   182         optimzed cf. http://stevesouders.com/cuzillion) order in external
   183         resources declaration
   183         resources declaration
   184         """
   184         """
   185         w = self.write
   185         w = self.write
   207         # 5/ post inlined scripts (i.e. scripts depending on other JS files)
   207         # 5/ post inlined scripts (i.e. scripts depending on other JS files)
   208         if self.post_inlined_scripts:
   208         if self.post_inlined_scripts:
   209             w(u'<script type="text/javascript">\n')
   209             w(u'<script type="text/javascript">\n')
   210             w(u'\n\n'.join(self.post_inlined_scripts))
   210             w(u'\n\n'.join(self.post_inlined_scripts))
   211             w(u'\n</script>\n')
   211             w(u'\n</script>\n')
   212         return u'<head>\n%s</head>\n' % super(HTMLHead, self).getvalue()
   212         header = super(HTMLHead, self).getvalue()
       
   213         if skiphead:
       
   214             return header
       
   215         return u'<head>\n%s</head>\n' % header
   213         
   216         
   214 
   217 
   215 class HTMLStream(object):
   218 class HTMLStream(object):
   216     """represents a HTML page.
   219     """represents a HTML page.
   217 
   220