Skip to content

Loading…

Fixed #20922 -- Customizable serializers for signed_cookie sessions #1474

Closed
wants to merge 1 commit into from

2 participants

@gavinwahl

Refactor the signed cookie session backend to allow subclassers to use a different serializer implementation.

For Ticket #20922

@gavinwahl gavinwahl Fixed #20922 -- Customizable serializers for signed_cookie sessions
Refactor the signed cookie session backend to allow subclassers to use a
different serializer implementation.
7a2f06e
@timgraham
Django member

Thanks for the report. I have a more extensive patch with docs, tests, etc. in the works so I'm going to close this for now.

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2013
  1. @gavinwahl

    Fixed #20922 -- Customizable serializers for signed_cookie sessions

    gavinwahl committed
    Refactor the signed cookie session backend to allow subclassers to use a
    different serializer implementation.
Showing with 3 additions and 2 deletions.
  1. +3 −2 django/contrib/sessions/backends/signed_cookies.py
View
5 django/contrib/sessions/backends/signed_cookies.py
@@ -22,6 +22,7 @@ def loads(self, data):
class SessionStore(SessionBase):
+ serializer = PickleSerializer
def load(self):
"""
@@ -31,7 +32,7 @@ def load(self):
"""
try:
return signing.loads(self.session_key,
- serializer=PickleSerializer,
+ serializer=self.serializer,
# This doesn't handle non-default expiry dates, see #19201
max_age=settings.SESSION_COOKIE_AGE,
salt='django.contrib.sessions.backends.signed_cookies')
@@ -91,7 +92,7 @@ def _get_session_key(self):
session_cache = getattr(self, '_session_cache', {})
return signing.dumps(session_cache, compress=True,
salt='django.contrib.sessions.backends.signed_cookies',
- serializer=PickleSerializer)
+ serializer=self.serializer)
@classmethod
def clear_expired(cls):
Something went wrong with that request. Please try again.