#23764: sessions.backends.cache.SessionStore does not respect
settings.SESSION_SERIALIZER
--------------------------------------+------------------------------------
Reporter: coagulant | Owner: r4vi
Type: Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: 1.7
Severity: Normal | Resolution:
Keywords: pickle json sessions | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by r4vi):
I've created a PR: https://github.com/django/django/pull/4372 and I'll
repeat the commnt here:
Have fixed `cache.SessionStore` to respect the SESSION_SERIALIZER setting.
The `django.contrib.sessions.backends.cache` now `.encode`s in the .save
method and `.decode`s in the load method.
I'm not sure how to add regression tests for this. One option is to add
this to the test.session_tests.tests.SessionTestsMixin:
{{{
def test_save_encodes(self):
# regression test for #23764
session = self.backend()
session.encode = mock.MagicMock(return_value='encoded')
session['some key'] = 'some unencoded value'
session.save()
session.encode.assert_called_with({'some key': 'some unencoded
value'})
}}}
but this tests for breaks `tests.sessions_tests.tests.CookieSessionTests`
because that backend gives self.serializer to the signer instead of using
it directly. I don't want to put an ugly
{{{
def test_save_encdoes(self):
pass
}}}
in there.
--
Ticket URL: <https://code.djangoproject.com/ticket/23764#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.89ac2afb531fee907a77dd51eb94327d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.