1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Removed a bunch of Python 2.4 workarounds now that we don't support it. Refs #15702 -- thanks to jonash for the patch. Splitting this over muliple commits to make it more manageable.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2011-03-28 01:40:43 +00:00
parent 18ef901e5f
commit a87be3554f
20 changed files with 50 additions and 63 deletions

View File

@@ -1,15 +1,15 @@
"File-based cache backend"
import hashlib
import os
import time
import shutil
import time
try:
import cPickle as pickle
except ImportError:
import pickle
from django.core.cache.backends.base import BaseCache
from django.utils.hashcompat import md5_constructor
class FileBasedCache(BaseCache):
def __init__(self, dir, params):
@@ -145,7 +145,7 @@ class FileBasedCache(BaseCache):
Thus, a cache key of "foo" gets turnned into a file named
``{cache-dir}ac/bd/18db4cc2f85cedef654fccc4a4d8``.
"""
path = md5_constructor(key).hexdigest()
path = hashlib.md5(key).hexdigest()
path = os.path.join(path[:2], path[2:4], path[4:])
return os.path.join(self._dir, path)

View File

@@ -77,12 +77,10 @@ class LocMemCache(BaseCache):
key = self.make_key(key, version=version)
self.validate_key(key)
self._lock.writer_enters()
# Python 2.4 doesn't allow combined try-except-finally blocks.
try:
try:
self._set(key, pickle.dumps(value), timeout)
except pickle.PickleError:
pass
self._set(key, pickle.dumps(value), timeout)
except pickle.PickleError:
pass
finally:
self._lock.writer_leaves()