fixed issue 1755:IE11 vs gluon.contrib.user_agent - 'browser' key not existing anymore
This commit is contained in:
@@ -405,7 +405,7 @@ def detect(agent):
|
||||
result['exception'] = ex
|
||||
# hack to address https://code.google.com/p/web2py/issues/detail?id=1755
|
||||
if not 'browser' in result:
|
||||
result['browser'] = Storage({'name':'IE11'})
|
||||
result['browser'] = {'name':'IE11'}
|
||||
return result
|
||||
|
||||
|
||||
|
||||
+4
-1
@@ -109,6 +109,7 @@ def listdir(
|
||||
drop=True,
|
||||
add_dirs=False,
|
||||
sort=True,
|
||||
maxnum = None,
|
||||
):
|
||||
"""
|
||||
like os.listdir() but you can specify a regex pattern to filter files.
|
||||
@@ -121,7 +122,7 @@ def listdir(
|
||||
else:
|
||||
n = 0
|
||||
regex = re.compile(expression)
|
||||
items = []
|
||||
items = []
|
||||
for (root, dirs, files) in os.walk(path, topdown=True):
|
||||
for dir in dirs[:]:
|
||||
if dir.startswith('.'):
|
||||
@@ -131,6 +132,8 @@ def listdir(
|
||||
for file in sorted(files):
|
||||
if regex.match(file) and not file.startswith('.'):
|
||||
items.append(os.path.join(root, file)[n:])
|
||||
if maxnum and len(items)>=maxnum:
|
||||
break
|
||||
if sort:
|
||||
return sorted(items)
|
||||
else:
|
||||
|
||||
+5
-5
@@ -294,14 +294,14 @@ class Request(Storage):
|
||||
def user_agent(self):
|
||||
from gluon.contrib import user_agent_parser
|
||||
session = current.session
|
||||
user_agent = session._user_agent or \
|
||||
user_agent_parser.detect(self.env.http_user_agent)
|
||||
if session:
|
||||
session._user_agent = user_agent
|
||||
user_agent = Storage(user_agent)
|
||||
user_agent = session._user_agent
|
||||
if user_agent:
|
||||
return user_agent
|
||||
user_agent = user_agent_parser.detect(self.env.http_user_agent)
|
||||
for key, value in user_agent.items():
|
||||
if isinstance(value, dict):
|
||||
user_agent[key] = Storage(value)
|
||||
user_agent = session._user_agent = Storage(user_agent)
|
||||
return user_agent
|
||||
|
||||
def requires_https(self):
|
||||
|
||||
Reference in New Issue
Block a user