Skip to content

Commit

Permalink
Fix locale_negotiator for fulltextsearch
Browse files Browse the repository at this point in the history
This function was relying on Piramid to use default_locale_name if no locale
is found. But fulltextsearch is using this function directly and was returing
status=500 if the browser's languages were not matching the list of available
languages.
  • Loading branch information
Patrick Valsecchi committed Mar 23, 2016
1 parent b0a6406 commit a5d5990
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions c2cgeoportal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ def _add_static_view(config, name, path):
def locale_negotiator(request):
lang = request.params.get("lang")
if lang is None:
# if best_match returns None then Pyramid will use what's defined in
# the default_locale_name configuration variable
# if best_match returns None then use the default_locale_name configuration variable
return request.accept_language.best_match(
request.registry.settings.get("available_locale_names"))
request.registry.settings.get("available_locale_names"),
default_match=request.registry.settings.get("default_locale_name"))
return lang


Expand Down
2 changes: 1 addition & 1 deletion c2cgeoportal/tests/test_locale_negociator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_lang_is_not_available(self):

request.headers["accept-language"] = "en-us,en;q=0.3,fr;q=0.7"
lang = locale_negotiator(request)
self.assertEquals(lang, None)
self.assertEquals(lang, "de")

def test_lang_is_available(self):
from c2cgeoportal import locale_negotiator
Expand Down

0 comments on commit a5d5990

Please sign in to comment.