mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Added support for time zones. Thanks Luke Plant for the review. Fixed #2626.
For more information on this project, see this thread: http://groups.google.com/group/django-developers/browse_thread/thread/cf0423bbb85b1bbf git-svn-id: http://code.djangoproject.com/svn/django/trunk@17106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -25,6 +25,7 @@ from django.conf import settings
|
||||
from django.core.cache import get_cache
|
||||
from django.utils.encoding import smart_str, iri_to_uri
|
||||
from django.utils.http import http_date
|
||||
from django.utils.timezone import get_current_timezone_name
|
||||
from django.utils.translation import get_language
|
||||
|
||||
cc_delim_re = re.compile(r'\s*,\s*')
|
||||
@@ -157,12 +158,14 @@ def has_vary_header(response, header_query):
|
||||
return header_query.lower() in existing_headers
|
||||
|
||||
def _i18n_cache_key_suffix(request, cache_key):
|
||||
"""If enabled, returns the cache key ending with a locale."""
|
||||
"""If necessary, adds the current locale or time zone to the cache key."""
|
||||
if settings.USE_I18N or settings.USE_L10N:
|
||||
# first check if LocaleMiddleware or another middleware added
|
||||
# LANGUAGE_CODE to request, then fall back to the active language
|
||||
# which in turn can also fall back to settings.LANGUAGE_CODE
|
||||
cache_key += '.%s' % getattr(request, 'LANGUAGE_CODE', get_language())
|
||||
if settings.USE_TZ:
|
||||
cache_key += '.%s' % get_current_timezone_name()
|
||||
return cache_key
|
||||
|
||||
def _generate_cache_key(request, method, headerlist, key_prefix):
|
||||
|
||||
Reference in New Issue
Block a user