--- documentViewer/documentViewer.py 2010/10/28 15:44:20 1.147 +++ documentViewer/documentViewer.py 2010/10/29 12:53:45 1.148 @@ -51,15 +51,32 @@ def serializeNode(node, encoding='utf-8' buf.close() return s -def getBrowserType(self): - """get browser type object""" - if self.REQUEST.SESSION.has_key('browserType'): - return self.REQUEST.SESSION['browserType'] - else: - bt = browserCheck(self) - self.REQUEST.SESSION.set('browserType', bt) - logging.debug("documentViewer (BROWSER TYPE) bt %s"%bt) - return bt +def browserCheck(self): + """check the browsers request to find out the browser type""" + bt = {} + ua = self.REQUEST.get_header("HTTP_USER_AGENT") + bt['ua'] = ua + bt['isIE'] = False + bt['isN4'] = False + if string.find(ua, 'MSIE') > -1: + bt['isIE'] = True + else: + bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1) + + try: + nav = ua[string.find(ua, '('):] + ie = string.split(nav, "; ")[1] + if string.find(ie, "MSIE") > -1: + bt['versIE'] = string.split(ie, " ")[1] + except: pass + + bt['isMac'] = string.find(ua, 'Macintosh') > -1 + bt['isWin'] = string.find(ua, 'Windows') > -1 + bt['isIEWin'] = bt['isIE'] and bt['isWin'] + bt['isIEMac'] = bt['isIE'] and bt['isMac'] + bt['staticHTML'] = False + + return bt def getParentDir(path): @@ -309,7 +326,12 @@ class documentViewer(Folder): ret+="mk=%s"%m return ret - + def getBrowser(self): + """getBrowser the version of browser """ + bt = browserCheck(self) + logging.debug("XXXXXXXXXXXXXXXX: %s"%bt) + return bt + def findDigilibUrl(self): """try to get the digilib URL from zogilib""" url = self.template.zogilib.getDLBaseUrl()