Author: russellm
Date: 2009-12-11 23:25:50 -0600 (Fri, 11 Dec 2009)
New Revision: 11814
Modified:
django/trunk/django/contrib/messages/storage/cookie.py
django/trunk/django/utils/hashcompat.py
Log:
Fixed #12362 -- Corrected Python 2.4 incompatibility with hmac constructor in
contrib.messages. Thanks to Jeremy Dunck for the report and patch.
Modified: django/trunk/django/contrib/messages/storage/cookie.py
===================================================================
--- django/trunk/django/contrib/messages/storage/cookie.py 2009-12-12
02:13:30 UTC (rev 11813)
+++ django/trunk/django/contrib/messages/storage/cookie.py 2009-12-12
05:25:50 UTC (rev 11814)
@@ -1,7 +1,7 @@
import hmac
from django.conf import settings
-from django.utils.hashcompat import sha_constructor
+from django.utils.hashcompat import sha_hmac
from django.contrib.messages import constants
from django.contrib.messages.storage.base import BaseStorage, Message
from django.utils import simplejson as json
@@ -41,7 +41,6 @@
decoded = super(MessageDecoder, self).decode(s, **kwargs)
return self.process_messages(decoded)
-
class CookieStorage(BaseStorage):
"""
Stores messages in a cookie.
@@ -103,7 +102,7 @@
SECRET_KEY, modified to make it unique for the present purpose.
"""
key = 'django.contrib.messages' + settings.SECRET_KEY
- return hmac.new(key, value, sha_constructor).hexdigest()
+ return hmac.new(key, value, sha_hmac).hexdigest()
def _encode(self, messages, encode_empty=False):
"""
Modified: django/trunk/django/utils/hashcompat.py
===================================================================
--- django/trunk/django/utils/hashcompat.py 2009-12-12 02:13:30 UTC (rev
11813)
+++ django/trunk/django/utils/hashcompat.py 2009-12-12 05:25:50 UTC (rev
11814)
@@ -8,9 +8,13 @@
try:
import hashlib
md5_constructor = hashlib.md5
+ md5_hmac = md5_constructor
sha_constructor = hashlib.sha1
+ sha_hmac = sha_constructor
except ImportError:
import md5
md5_constructor = md5.new
+ md5_hmac = md5
import sha
sha_constructor = sha.new
+ sha_hmac = sha
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.