Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Quite the deprecation warnings under Python 2.6 and upwards on the us…
Browse files Browse the repository at this point in the history
…e of the md5 module

Patch suggested by Satoru SATOH <satoru.satoh@gmail.com> with minor tweaks in order to properly be backwards compatible to versions prior to Python 2.6

Signed-off-by: R. Tyler Ballance <tyler@slide.com>
  • Loading branch information
R. Tyler Ballance committed Mar 16, 2009
1 parent 126324e commit ef3d0c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/CacheRegion.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@
__author__ = "Tavis Rudd <tavis@damnsimple.com> and Philippe Normand <phil@base-art.net>"
__revision__ = "$Revision: 1.3 $"[11:-2]

import md5
try:
import hashlib
def md5digest(material):
return hashlib.md5(material).digest()
except ImportError:
import md5
def md5digest(material):
return md5.new(material).hexdigest()

from time import time as currentTime
from Cheetah.CacheStore import MemoryCacheStore

Expand Down Expand Up @@ -128,8 +136,8 @@ def getCacheItem(self, cacheItemID):
Returns a `CacheItem` instance.
"""
cacheItemID = md5.new(str(cacheItemID)).hexdigest()
cacheItemID = md5digest(str(cacheItemID))

if not self._cacheItems.has_key(cacheItemID):
cacheItem = self._cacheItemClass(
cacheItemID=cacheItemID, cacheStore=self._wrappedCacheDataStore)
Expand Down

0 comments on commit ef3d0c7

Please sign in to comment.