Commit 6218ccc5 authored by Dan McGee's avatar Dan McGee
Browse files

Use python hashlib directly

Django hashcompat is now deprecated.

Signed-off-by: default avatarDan McGee <>
parent 7896779f
import hashlib
import pytz
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
from django.db.models import Q
from django.utils.feedgenerator import Rss201rev2Feed
from django.utils.hashcompat import md5_constructor
from django.views.decorators.http import condition
from main.utils import retrieve_latest
......@@ -32,7 +32,7 @@ def write_items(self, handler):
def package_etag(request, *args, **kwargs):
latest = retrieve_latest(Package)
if latest:
return md5_constructor(str(kwargs) + str(latest)).hexdigest()
return hashlib.md5(str(kwargs) + str(latest)).hexdigest()
return None
def package_last_modified(request, *args, **kwargs):
......@@ -108,7 +108,7 @@ def item_categories(self, item):
def news_etag(request, *args, **kwargs):
latest = retrieve_latest(News)
if latest:
return md5_constructor(str(latest)).hexdigest()
return hashlib.md5(str(latest)).hexdigest()
return None
def news_last_modified(request, *args, **kwargs):
......@@ -4,9 +4,9 @@
import pickle
from datetime import datetime
import hashlib
from django.core.cache import cache
from django.utils.hashcompat import md5_constructor
......@@ -15,7 +15,7 @@
def cache_function_key(func, args, kwargs):
raw = [func.__name__, func.__module__, args, kwargs]
pickled = pickle.dumps(raw, protocol=pickle.HIGHEST_PROTOCOL)
key = md5_constructor(pickled).hexdigest()
key = hashlib.md5(pickled).hexdigest()
return 'cache_function.' + func.__name__ + '.' + key
def cache_function(length):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment