Mercurial > hg > documentViewer
diff SrvTxtUtils.py @ 585:83eeed69793f
new annotator layer for images.
author | casties |
---|---|
date | Tue, 13 Nov 2012 17:33:34 +0100 |
parents | 2fe04b61ed95 |
children | c57d80a649ea |
line wrap: on
line diff
--- a/SrvTxtUtils.py Mon Nov 12 18:13:33 2012 +0100 +++ b/SrvTxtUtils.py Tue Nov 13 17:33:34 2012 +0100 @@ -11,7 +11,7 @@ import logging -srvTxtUtilsVersion = "1.5.1" +srvTxtUtilsVersion = "1.6" def getInt(number, default=0): """returns always an int (0 in case of problems)""" @@ -132,3 +132,32 @@ # call original method return ImageFile.index_html(self, REQUEST, RESPONSE) + +def getBrowserType(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 + +