Author: aaugustin
Date: 2012-03-23 09:14:46 -0700 (Fri, 23 Mar 2012)
New Revision: 17797
Modified:
django/trunk/django/contrib/sessions/backends/cache.py
django/trunk/django/contrib/sessions/backends/cached_db.py
Log:
Fixed #17810 (again). Catch session key errors.
The previous commit didn't work with PyLibMC.
This solution appears to be the best compromise
at this point in the 1.4 release cycle.
Modified: django/trunk/django/contrib/sessions/backends/cache.py
===================================================================
--- django/trunk/django/contrib/sessions/backends/cache.py 2012-03-23
09:32:11 UTC (rev 17796)
+++ django/trunk/django/contrib/sessions/backends/cache.py 2012-03-23
16:14:46 UTC (rev 17797)
@@ -19,10 +19,9 @@
def load(self):
try:
session_data = self._cache.get(self.cache_key, None)
- except Exception, e:
- e_type = str(type(e))
- if e_type != "<class 'memcache.MemcachedKeyLengthError'>":
- raise e
+ except Exception:
+ # Some backends (e.g. memcache) raise an exception on invalid
+ # cache keys. If this happens, reset the session. See #17810.
session_data = None
if session_data is not None:
return session_data
Modified: django/trunk/django/contrib/sessions/backends/cached_db.py
===================================================================
--- django/trunk/django/contrib/sessions/backends/cached_db.py 2012-03-23
09:32:11 UTC (rev 17796)
+++ django/trunk/django/contrib/sessions/backends/cached_db.py 2012-03-23
16:14:46 UTC (rev 17797)
@@ -24,10 +24,9 @@
def load(self):
try:
data = cache.get(self.cache_key, None)
- except Exception, e:
- e_type = str(type(e))
- if e_type != "<class 'memcache.MemcachedKeyLengthError'>":
- raise e
+ except Exception:
+ # Some backends (e.g. memcache) raise an exception on invalid
+ # cache keys. If this happens, reset the session. See #17810.
data = None
if data is None:
data = super(SessionStore, self).load()
--
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.