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