web/request.py
branchtls-sprint
changeset 1421 77ee26df178f
parent 1173 8f123fd081f4
child 1426 379261551578
equal deleted inserted replaced
1420:25c13e5b12bd 1421:77ee26df178f
    54     return [v for v in value if v != INTERNAL_FIELD_VALUE]
    54     return [v for v in value if v != INTERNAL_FIELD_VALUE]
    55 
    55 
    56 
    56 
    57 
    57 
    58 class CubicWebRequestBase(DBAPIRequest):
    58 class CubicWebRequestBase(DBAPIRequest):
    59     """abstract HTTP request, should be extended according to the HTTP backend"""    
    59     """abstract HTTP request, should be extended according to the HTTP backend"""
    60     
    60 
    61     def __init__(self, vreg, https, form=None):
    61     def __init__(self, vreg, https, form=None):
    62         super(CubicWebRequestBase, self).__init__(vreg)
    62         super(CubicWebRequestBase, self).__init__(vreg)
    63         self.message = None
    63         self.message = None
    64         self.authmode = vreg.config['auth-mode']
    64         self.authmode = vreg.config['auth-mode']
    65         self.https = https
    65         self.https = https
   655         useragent = self.useragent()
   655         useragent = self.useragent()
   656         return useragent and 'MSIE' in useragent
   656         return useragent and 'MSIE' in useragent
   657     
   657     
   658     def xhtml_browser(self):
   658     def xhtml_browser(self):
   659         useragent = self.useragent()
   659         useragent = self.useragent()
   660         # MSIE does not support xml content-type
   660         # * MSIE/Konqueror does not support xml content-type
   661         # quick fix: Opera supports xhtml and handles namespaces
   661         # * Opera supports xhtml and handles namespaces properly but it breaks
   662         # properly but it breaks jQuery.attr()
   662         #   jQuery.attr()
   663         if useragent and ('MSIE' in useragent or 'KHTML' in useragent
   663         if useragent and ('MSIE' in useragent or 'KHTML' in useragent
   664                           or 'Opera' in useragent):
   664                           or 'Opera' in useragent):
   665             return False
   665             return False
   666         return True
   666         return True
   667 
   667 
       
   668     def html_content_type(self):
       
   669         if self.xhtml_browser():
       
   670             return 'application/xhtml+xml'
       
   671         return 'text/html'
       
   672 
   668 from cubicweb import set_log_methods
   673 from cubicweb import set_log_methods
   669 set_log_methods(CubicWebRequestBase, LOGGER)
   674 set_log_methods(CubicWebRequestBase, LOGGER)