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.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@17797 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Aymeric Augustin 2012-03-23 16:14:46 +00:00
parent 46871eb1bb
commit f356a2e52f
2 changed files with 6 additions and 8 deletions

View File

@ -19,10 +19,9 @@ class SessionStore(SessionBase):
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

View File

@ -24,10 +24,9 @@ class SessionStore(DBStore):
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()