From 93249b4cb9fec0fc8e0d2fd2eff669e9f3704033 Mon Sep 17 00:00:00 2001 From: Stephen Burrows Date: Mon, 28 Mar 2011 14:21:28 -0400 Subject: [PATCH] Removed python 2.4 compatibility workaround use, since this is removed in Django 1.3 and philo doesn't support python 2.4 anyway. --- contrib/sobol/admin.py | 2 +- contrib/sobol/utils.py | 4 ++-- contrib/waldo/tokens.py | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/contrib/sobol/admin.py b/contrib/sobol/admin.py index 504cde2..87dd39a 100644 --- a/contrib/sobol/admin.py +++ b/contrib/sobol/admin.py @@ -6,10 +6,10 @@ from django.db.models import Count from django.http import HttpResponseRedirect, Http404 from django.shortcuts import render_to_response from django.template import RequestContext -from django.utils.functional import update_wrapper from django.utils.translation import ugettext_lazy as _ from philo.admin import EntityAdmin from philo.contrib.sobol.models import Search, ResultURL, SearchView +from functools import update_wrapper class ResultURLInline(admin.TabularInline): diff --git a/contrib/sobol/utils.py b/contrib/sobol/utils.py index 723a463..3c5e537 100644 --- a/contrib/sobol/utils.py +++ b/contrib/sobol/utils.py @@ -1,8 +1,8 @@ from django.conf import settings from django.http import QueryDict from django.utils.encoding import smart_str -from django.utils.hashcompat import sha_constructor from django.utils.http import urlquote_plus, urlquote +from hashlib import sha1 SEARCH_ARG_GET_KEY = 'q' @@ -11,7 +11,7 @@ HASH_REDIRECT_GET_KEY = 's' def make_redirect_hash(search_arg, url): - return sha_constructor(smart_str(search_arg + url + settings.SECRET_KEY)).hexdigest()[::2] + return sha1(smart_str(search_arg + url + settings.SECRET_KEY)).hexdigest()[::2] def check_redirect_hash(hash, search_arg, url): diff --git a/contrib/waldo/tokens.py b/contrib/waldo/tokens.py index 95ce0c0..80f0b11 100644 --- a/contrib/waldo/tokens.py +++ b/contrib/waldo/tokens.py @@ -7,6 +7,7 @@ from datetime import date from django.conf import settings from django.utils.http import int_to_base36, base36_to_int from django.contrib.auth.tokens import PasswordResetTokenGenerator +from hashlib import sha1 REGISTRATION_TIMEOUT_DAYS = getattr(settings, 'WALDO_REGISTRATION_TIMEOUT_DAYS', 1) @@ -52,8 +53,7 @@ class RegistrationTokenGenerator(PasswordResetTokenGenerator): # By hashing on the internal state of the user and using state that is # sure to change, we produce a hash that will be invalid as soon as it # is used. - from django.utils.hashcompat import sha_constructor - hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) + unicode(user.is_active) + user.last_login.strftime('%Y-%m-%d %H:%M:%S') + unicode(timestamp)).hexdigest()[::2] + hash = sha1(settings.SECRET_KEY + unicode(user.id) + unicode(user.is_active) + user.last_login.strftime('%Y-%m-%d %H:%M:%S') + unicode(timestamp)).hexdigest()[::2] return '%s-%s' % (ts_b36, hash) @@ -98,8 +98,7 @@ class EmailTokenGenerator(PasswordResetTokenGenerator): def _make_token_with_timestamp(self, user, email, timestamp): ts_b36 = int_to_base36(timestamp) - from django.utils.hashcompat import sha_constructor - hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) + user.email + email + unicode(timestamp)).hexdigest()[::2] + hash = sha1(settings.SECRET_KEY + unicode(user.id) + user.email + email + unicode(timestamp)).hexdigest()[::2] return '%s-%s' % (ts_b36, hash) -- 2.20.1