Replace hashlib by django's md5_constructor

This commit is contained in:
Mathieu Pillard 2010-02-18 18:48:14 +01:00 committed by Eric Florenzano
parent 984131894b
commit c364ca7aa1

View file

@ -5,7 +5,7 @@ from django.db import models
from django.contrib.auth.models import User
from django.core.files.base import ContentFile
from django.utils.translation import ugettext as _
import hashlib
from django.utils.hashcompat import md5_constructor
try:
from cStringIO import StringIO
@ -24,7 +24,7 @@ from avatar import AVATAR_STORAGE_DIR, AVATAR_RESIZE_METHOD, \
def avatar_file_path(instance=None, filename=None, size=None, ext=None):
tmppath = [AVATAR_STORAGE_DIR]
if AVATAR_HASH_USERDIRNAMES:
tmp = hashlib.md5(instance.user.username).hexdigest()
tmp = md5_constructor(instance.user.username).hexdigest()
tmppath.extend([tmp[0], tmp[1], instance.user.username])
else:
tmppath.append(instance.user.username)
@ -42,7 +42,7 @@ def avatar_file_path(instance=None, filename=None, size=None, ext=None):
# File doesn't exist yet
if AVATAR_HASH_FILENAMES:
(root, ext) = os.path.splitext(filename)
filename = hashlib.md5(filename).hexdigest()
filename = md5_constructor(filename).hexdigest()
filename = filename + ext
if size:
tmppath.extend(['resized', str(size)])