Opened 14 years ago
Closed 11 years ago
#14170 closed Bug (fixed)
Issue in get_language_from_request() if LANGUAGES setting is changed at runtime
Reported by: | German M. Bravo | Owned by: | Bouke Haarsma |
---|---|---|---|
Component: | Internationalization | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | German M. Bravo | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In get_language_from_request() in the translation module (trans_real.py), when you have multiple requests to it, and in requests you for some reason change the LANGUAGES setting... get_language_from_request() breaks the supported languages, because it assumes settings.LANGUAGES will never change, and it stores in _accepted the accepted .mo files (which's found they exist in the path), but in the next request, if the LANGUAGES changed, and the .mo file exists, it no longer checks for it to be supported in the new settings.LANGUAGES...
I know you shouldn't be changing settings such as LANGUAGES between requests, django doesn't even fully support it (thread safe, that's why I added the patch in ticket #12737)...but anyway, the thing is that if django is assumed not to ever change anything in the settings, many other things could probably be further optimized, but they're not, but it all generally works just fine (using the thread safe settings I mentioned), except for this time. I'm attaching a patch that would allow it to cache the _accepted found .mo files, but still check every time the _accepted language is really currently supported.
Attachments (1)
Change History (10)
by , 14 years ago
Attachment: | get_language_from_request.diff added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Summary: | Issue in get_language_from_request() ? → Issue in get_language_from_request() if LNGUAGES setting si changed at runtime |
---|---|
Triage Stage: | Unreviewed → Someday/Maybe |
comment:3 by , 14 years ago
Summary: | Issue in get_language_from_request() if LNGUAGES setting si changed at runtime → Issue in get_language_from_request() if LANGUAGES setting is changed at runtime |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:5 by , 13 years ago
Cc: | added |
---|---|
Easy pickings: | unset |
UI/UX: | unset |
comment:6 by , 12 years ago
Triage Stage: | Someday/Maybe → Accepted |
---|
The solution is to implement a setting_changed
listener that resets the caches.
comment:7 by , 12 years ago
Component: | Core (Other) → Internationalization |
---|
comment:8 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I've provided a fix for this issue in a PR: https://github.com/django/django/pull/1821
comment:9 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
See #14628 re: Documenting which settings can be modified.