# HG changeset patch # User Sylvain Thénault # Date 1320685720 -3600 # Node ID 1b2a05c9b71c4148eb0bf898f812e8c1c6574313 # Parent ffd510fb71dad0e6e84965dec62ed2ea70c2630b [html, ajax] demote_to_html don't crash anymore if force-html-content-type is activated. Closes #712309 diff -r ffd510fb71da -r 1b2a05c9b71c web/request.py --- a/web/request.py Fri Nov 04 17:29:39 2011 +0100 +++ b/web/request.py Mon Nov 07 18:08:40 2011 +0100 @@ -795,8 +795,13 @@ The global doctype and xmldec must also be changed otherwise the browser will display '<[' at the beginning of the page """ - self.set_content_type('text/html') - self.main_stream.set_doctype(TRANSITIONAL_DOCTYPE_NOEXT) + if not self.vreg.config['force-html-content-type']: + if not hasattr(self, 'main_stream'): + raise Exception("Can't demote to html from an ajax context. You " + "should change force-html-content-type to yes " + "in the instance configuration file.") + self.set_content_type('text/html') + self.main_stream.set_doctype(TRANSITIONAL_DOCTYPE_NOEXT) def set_doctype(self, doctype, reset_xmldecl=True): """helper method to dynamically change page doctype