summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-23 17:48:43 -0500
committerDan McGee <dan@archlinux.org>2012-03-23 19:54:40 -0500
commit6218ccc570c674bfaaf1c636382ac6f9adbf212b (patch)
tree736e5a3200d322ff5eb4019786891e198860c273
parent7896779ff18b304f8246c24123b8cbf9b82ec5b0 (diff)
downloadarchweb-6218ccc570c674bfaaf1c636382ac6f9adbf212b.tar.gz
archweb-6218ccc570c674bfaaf1c636382ac6f9adbf212b.zip
Use python hashlib directly
Django hashcompat is now deprecated. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--feeds.py6
-rw-r--r--main/utils.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/feeds.py b/feeds.py
index 74ae9ff9..ee856f62 100644
--- a/feeds.py
+++ b/feeds.py
@@ -1,10 +1,10 @@
+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 @@ class GuidNotPermalinkFeed(Rss201rev2Feed):
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 @@ class PackageFeed(Feed):
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):
diff --git a/main/utils.py b/main/utils.py
index 81f689e7..03441c15 100644
--- a/main/utils.py
+++ b/main/utils.py
@@ -4,9 +4,9 @@ except ImportError:
import pickle
from datetime import datetime
+import hashlib
from django.core.cache import cache
-from django.utils.hashcompat import md5_constructor
CACHE_TIMEOUT = 1800
INVALIDATE_TIMEOUT = 10
@@ -15,7 +15,7 @@ CACHE_LATEST_PREFIX = 'cache_latest_'
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):