[Debexpo-devel] [debexpo] 03/06: pylons 1.0.1 seems to be buggy regarding ua languages, so just ignore them if it crashes
Mattia Rizzolo
mattia at debian.org
Fri Feb 23 16:48:39 UTC 2018
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch live
in repository debexpo.
commit 9de41f8b2e7b2670174885350c6ccbf9b6537916
Author: Debexpo Live User <expo at wv-debian-mentors1.wavecloud.de>
Date: Fri Feb 23 15:57:08 2018 +0000
pylons 1.0.1 seems to be buggy regarding ua languages, so just ignore them if it crashes
---
debexpo/lib/base.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/debexpo/lib/base.py b/debexpo/lib/base.py
index 18f3954..b9aa5ed 100644
--- a/debexpo/lib/base.py
+++ b/debexpo/lib/base.py
@@ -40,6 +40,9 @@ __author__ = 'Jonny Lamb'
__copyright__ = 'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner, Copyright © 2011 Arno Töll'
__license__ = 'MIT'
+import logging
+log = logging.getLogger(__name__)
+
from pylons import tmpl_context as c, cache, config, app_globals, request, \
response, session, url
from pylons.controllers import WSGIController
@@ -112,9 +115,19 @@ class BaseController(WSGIController):
def __before__(self):
# Set language according to what the browser requested
- user_agent_language = request.languages[0][0:2]
- if user_agent_language in app_globals.supported_languages:
- set_lang(user_agent_language)
+ try:
+ languages = request.languages
+ except AttributeError:
+ log.debug("Working around Pylons request.languages bug")
+ languages = []
+
+ for ua_lang in languages:
+ log.debug("Trying user agent language %s" % ua_lang)
+ # only get the main language code (fr_FR -> fr)
+ ua_lang = ua_lang[0:2]
+ if ua_lang in app_globals.supported_languages:
+ set_lang(ua_lang)
+ break
else:
set_lang(app_globals.default_language)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debexpo/debexpo.git
More information about the Debexpo-devel
mailing list