web/request.py
changeset 8064 6d8eb873256d
parent 8032 bcb87336c7d2
parent 8063 1b2a05c9b71c
child 8082 1c37783ff610
--- a/web/request.py	Mon Nov 07 10:56:39 2011 +0100
+++ b/web/request.py	Mon Nov 07 18:09:13 2011 +0100
@@ -793,8 +793,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