Ticket #12794: cooki18n.patch

File cooki18n.patch, 3.0 KB (added by Raymond Penners, 13 years ago)

No longer store language in session

  • django/views/i18n.py

     
    2929    if request.method == 'POST':
    3030        lang_code = request.POST.get('language', None)
    3131        if lang_code and check_for_language(lang_code):
    32             if hasattr(request, 'session'):
     32            if False and hasattr(request, 'session'):
    3333                request.session['django_language'] = lang_code
    3434            else:
    3535                response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
  • django/utils/translation/trans_real.py

     
    375375    if lang_code is not None:
    376376        return lang_code
    377377
    378     if hasattr(request, 'session'):
     378    if False and hasattr(request, 'session'):
    379379        lang_code = request.session.get('django_language', None)
    380380        if lang_code in supported and lang_code is not None and check_for_language(lang_code):
    381381            return lang_code
  • django/middleware/locale.py

     
    11"This is the locale selecting middleware that will look at accept headers"
    22
     3from django.conf import settings
    34from django.core.urlresolvers import get_resolver, LocaleRegexURLResolver
    45from django.http import HttpResponseRedirect
    56from django.utils.cache import patch_vary_headers
     
    3233        patch_vary_headers(response, ('Accept-Language',))
    3334        if 'Content-Language' not in response:
    3435            response['Content-Language'] = language
     36        if not response.cookies.has_key(settings.LANGUAGE_COOKIE_NAME):
     37            response.set_cookie(settings.LANGUAGE_COOKIE_NAME,
     38                                language)
    3539        return response
    3640
    3741    def is_language_prefix_patterns_used(self):
  • tests/regressiontests/views/tests/i18n.py

     
    1919            post_data = dict(language=lang_code, next='/views/')
    2020            response = self.client.post('/views/i18n/setlang/', data=post_data)
    2121            self.assertRedirects(response, 'http://testserver/views/')
    22             self.assertEqual(self.client.session['django_language'], lang_code)
     22            if False:
     23                self.assertEqual(self.client.session['django_language'],
     24                                 lang_code)
     25            else:
     26                self.assertEqual \
     27                    (response.cookies[settings.LANGUAGE_COOKIE_NAME].value,
     28                     lang_code)
    2329
    2430    def test_jsi18n(self):
    2531        """The javascript_catalog can be deployed with language settings"""
Back to Top