[req] hashlib has no hash function, but has an hash1 function even in python 2.5 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 05 Jul 2010 17:02:11 +0200
branchstable
changeset 5884 a0eb685dfe7a
parent 5867 7ef636d24ab2
child 5885 5d908f1a7659
[req] hashlib has no hash function, but has an hash1 function even in python 2.5
web/request.py
--- a/web/request.py	Fri Jul 02 14:47:34 2010 +0200
+++ b/web/request.py	Mon Jul 05 17:02:11 2010 +0200
@@ -20,12 +20,7 @@
 __docformat__ = "restructuredtext en"
 
 import Cookie
-try:
-    import hashlib
-    hashlib.hash
-except AttributeError:
-    # python 2.5 ...
-    import sha as hashlib
+import hashlib
 import time
 import random
 import base64
@@ -364,9 +359,9 @@
 
     def register_onetime_callback(self, func, *args):
         cbname = 'cb_%s' % (
-            hashlib.sha('%s%s%s%s' % (time.time(), func.__name__,
-                                      random.random(),
-                                      self.user.login)).hexdigest())
+            hashlib.sha1('%s%s%s%s' % (time.time(), func.__name__,
+                                       random.random(),
+                                       self.user.login)).hexdigest())
         def _cb(req):
             try:
                 ret = func(req, *args)