moksha/middleware/csrf.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
New commits:
commit 5ba82a3e86863e3cae2edf95f8fa24c378457837
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Apr 15 09:19:53 2009 -0400
Don't require the third-party hashlib module, and fallback to the sha module.
It seems that with python2.4 and the third-party hashlib module, there are
some serious problems with TG2/beaker:
http://trac.turbogears.org/ticket/2133
diff --git a/moksha/middleware/csrf.py b/moksha/middleware/csrf.py
index 2b87d58..ddab4e1 100644
--- a/moksha/middleware/csrf.py
+++ b/moksha/middleware/csrf.py
@@ -27,7 +27,6 @@ import logging
from tg import config
from webob import Request, Response
-from hashlib import sha1
from paste.request import construct_url
from paste.httpexceptions import HTTPFound
from paste.request import parse_formvars, parse_dict_querystring
@@ -36,6 +35,11 @@ from urlparse import urlparse, urlunparse
from repoze.who.interfaces import IMetadataProvider
from zope.interface import implements
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import sha as sha1
+
log = logging.getLogger(__name__)
class CSRFProtectionMiddleware(object):