web/request.py
changeset 3163 edfe43ceaa35
parent 2801 7ef4c1c9266b
parent 3094 978ed8c2c0e4
child 3293 69c0ba095536
--- a/web/request.py	Wed Sep 02 16:42:07 2009 +0200
+++ b/web/request.py	Thu Sep 10 08:13:22 2009 +0200
@@ -27,7 +27,7 @@
 from cubicweb.common.mail import header
 from cubicweb.common.uilib import remove_html_tags
 from cubicweb.utils import SizeConstrainedList, HTMLHead
-from cubicweb.view import STRICT_DOCTYPE
+from cubicweb.view import STRICT_DOCTYPE, TRANSITIONAL_DOCTYPE_NOEXT
 from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit,
                           RequestError, StatusResponse)
 
@@ -689,6 +689,16 @@
         """
         raise NotImplementedError()
 
+    def demote_to_html(self):
+        """helper method to dynamically set request content type to text/html
+
+        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.doctype = TRANSITIONAL_DOCTYPE_NOEXT
+        self.main_stream.xmldecl = u''
+
     # page data management ####################################################
 
     def get_page_data(self, key, default=None):