web/request.py
changeset 8064 6d8eb873256d
parent 8032 bcb87336c7d2
parent 8063 1b2a05c9b71c
child 8082 1c37783ff610
equal deleted inserted replaced
8061:88ca47ceb9f2 8064:6d8eb873256d
   791         """helper method to dynamically set request content type to text/html
   791         """helper method to dynamically set request content type to text/html
   792 
   792 
   793         The global doctype and xmldec must also be changed otherwise the browser
   793         The global doctype and xmldec must also be changed otherwise the browser
   794         will display '<[' at the beginning of the page
   794         will display '<[' at the beginning of the page
   795         """
   795         """
   796         self.set_content_type('text/html')
   796         if not self.vreg.config['force-html-content-type']:
   797         self.main_stream.set_doctype(TRANSITIONAL_DOCTYPE_NOEXT)
   797             if not hasattr(self, 'main_stream'):
       
   798                 raise Exception("Can't demote to html from an ajax context. You "
       
   799                                 "should change force-html-content-type to yes "
       
   800                                 "in the instance configuration file.")
       
   801             self.set_content_type('text/html')
       
   802             self.main_stream.set_doctype(TRANSITIONAL_DOCTYPE_NOEXT)
   798 
   803 
   799     def set_doctype(self, doctype, reset_xmldecl=True):
   804     def set_doctype(self, doctype, reset_xmldecl=True):
   800         """helper method to dynamically change page doctype
   805         """helper method to dynamically change page doctype
   801 
   806 
   802         :param doctype: the new doctype, e.g. '<!DOCTYPE html>'
   807         :param doctype: the new doctype, e.g. '<!DOCTYPE html>'