move test on force-html-content-type to xhtml_browser method
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Jul 2009 10:43:30 +0200
changeset 2558 81c8b5312f9c
parent 2557 200985d3258d
child 2559 46859078c866
move test on force-html-content-type to xhtml_browser method
view.py
web/request.py
--- a/view.py	Tue Jul 28 22:22:08 2009 +0200
+++ b/view.py	Wed Jul 29 10:43:30 2009 +0200
@@ -403,7 +403,7 @@
 
     @property
     def doctype(self):
-        if not self.config['force-html-content-type'] and self.req.xhtml_browser():
+        if self.req.xhtml_browser():
             return STRICT_DOCTYPE
         return STRICT_DOCTYPE_NOEXT
 
--- a/web/request.py	Tue Jul 28 22:22:08 2009 +0200
+++ b/web/request.py	Wed Jul 29 10:43:30 2009 +0200
@@ -699,6 +699,14 @@
         return useragent and 'MSIE' in useragent
 
     def xhtml_browser(self):
+        """return True if the browser is considered as xhtml compatible.
+
+        If the instance is configured to always return text/html and not
+        application/xhtml+xml, this method will always return False, even though
+        this is semantically different
+        """
+        if self.vreg.config['force-html-content-type']:
+            return False
         useragent = self.useragent()
         # * MSIE/Konqueror does not support xml content-type
         # * Opera supports xhtml and handles namespaces properly but it breaks
@@ -709,7 +717,7 @@
         return True
 
     def html_content_type(self):
-        if not self.vreg.config['force-html-content-type'] and self.xhtml_browser():
+        if self.xhtml_browser():
             return 'application/xhtml+xml'
         return 'text/html'