diff -r ae898a084da2 -r 7b26fe71404f utils.py --- a/utils.py Fri Apr 26 11:53:47 2013 +0200 +++ b/utils.py Fri Apr 26 12:10:37 2013 +0200 @@ -229,11 +229,8 @@ jQuery(window).unload(unloadPageData); pageDataUnloaded = true; }''' - # Making ' + script_opening = u'' def __init__(self, req): super(HTMLHead, self).__init__() @@ -344,14 +341,14 @@ w = self.write # 1/ variable declaration if any if self.jsvars: - w(self.xhtml_safe_script_opening) + w(self.script_opening) for var, value, override in self.jsvars: vardecl = u'%s = %s;' % (var, json.dumps(value)) if not override: vardecl = (u'if (typeof %s == "undefined") {%s}' % (var, vardecl)) w(vardecl + u'\n') - w(self.xhtml_safe_script_closing) + w(self.script_closing) # 2/ css files ie_cssfiles = ((x, (y, z)) for x, y, z in self.ie_cssfiles) if self.datadir_url and self._cw.vreg.config['concat-resources']: @@ -397,9 +394,9 @@ w(xml_escape(script)) w(u'') else: - w(self.xhtml_safe_script_opening) + w(self.script_opening) w(u'\n\n'.join(self.post_inlined_scripts)) - w(self.xhtml_safe_script_closing) + w(self.script_closing) header = super(HTMLHead, self).getvalue() if skiphead: return header @@ -422,20 +419,17 @@ # main stream self.body = UStringIO() self.doctype = u'' - # xmldecl and html opening tag - self.xmldecl = u'\n' % req.encoding - self._namespaces = [('xmlns', 'http://www.w3.org/1999/xhtml'), - ('xmlns:cubicweb','http://www.logilab.org/2008/cubicweb')] - self._htmlattrs = [('xml:lang', req.lang), - ('lang', req.lang)] + self._htmlattrs = [('lang', req.lang)] # keep main_stream's reference on req for easier text/html demoting req.main_stream = self + @deprecated('[3.17] there are no namespaces in html, xhtml is not served any longer') def add_namespace(self, prefix, uri): - self._namespaces.append( (prefix, uri) ) + pass + @deprecated('[3.17] there are no namespaces in html, xhtml is not served any longer') def set_namespaces(self, namespaces): - self._namespaces = namespaces + pass def add_htmlattr(self, attrname, attrvalue): self._htmlattrs.append( (attrname, attrvalue) ) @@ -443,10 +437,11 @@ def set_htmlattrs(self, attrs): self._htmlattrs = attrs - def set_doctype(self, doctype, reset_xmldecl=True): + def set_doctype(self, doctype, reset_xmldecl=None): self.doctype = doctype - if reset_xmldecl: - self.xmldecl = u'' + if reset_xmldecl is not None: + warn('[3.17] xhtml is no more supported', + DeprecationWarning, stacklevel=2) def write(self, data): """StringIO interface: this method will be assigned to self.w @@ -456,17 +451,17 @@ @property def htmltag(self): attrs = ' '.join('%s="%s"' % (attr, xml_escape(value)) - for attr, value in (self._namespaces + self._htmlattrs)) + for attr, value in self._htmlattrs) if attrs: return '' % attrs return '' def getvalue(self): """writes HTML headers, closes tag and writes HTML body""" - return u'%s\n%s\n%s\n%s\n%s\n' % (self.xmldecl, self.doctype, - self.htmltag, - self.head.getvalue(), - self.body.getvalue()) + return u'%s\n%s\n%s\n%s\n' % (self.doctype, + self.htmltag, + self.head.getvalue(), + self.body.getvalue()) try: # may not be there if cubicweb-web not installed