mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Fixed #7919 -- md5 and sha modules are deprecated since Python 2.5, use hashlib module when available. Patch from Karen Tracey.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8193 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -17,7 +17,6 @@ An example: i18n middleware would need to distinguish caches by the
|
||||
"Accept-language" header.
|
||||
"""
|
||||
|
||||
import md5
|
||||
import re
|
||||
import time
|
||||
try:
|
||||
@@ -29,6 +28,7 @@ from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.utils.encoding import smart_str, iri_to_uri
|
||||
from django.utils.http import http_date
|
||||
from django.utils.hashcompat import md5_constructor
|
||||
|
||||
cc_delim_re = re.compile(r'\s*,\s*')
|
||||
|
||||
@@ -104,7 +104,7 @@ def patch_response_headers(response, cache_timeout=None):
|
||||
if cache_timeout < 0:
|
||||
cache_timeout = 0 # Can't have max-age negative
|
||||
if not response.has_header('ETag'):
|
||||
response['ETag'] = '"%s"' % md5.new(response.content).hexdigest()
|
||||
response['ETag'] = '"%s"' % md5_constructor(response.content).hexdigest()
|
||||
if not response.has_header('Last-Modified'):
|
||||
response['Last-Modified'] = http_date()
|
||||
if not response.has_header('Expires'):
|
||||
@@ -138,7 +138,7 @@ def patch_vary_headers(response, newheaders):
|
||||
|
||||
def _generate_cache_key(request, headerlist, key_prefix):
|
||||
"""Returns a cache key from the headers given in the header list."""
|
||||
ctx = md5.new()
|
||||
ctx = md5_constructor()
|
||||
for header in headerlist:
|
||||
value = request.META.get(header, None)
|
||||
if value is not None:
|
||||
|
||||
Reference in New Issue
Block a user