#26503: SessionStore is not behaving as documented
----------------------------------+--------------------
Reporter: jmcbailey | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------
The documentation at
https://docs.djangoproject.com/en/1.8/topics/http/sessions/#using-
sessions-out-of-views has the following example:
{{{#!python
from django.contrib.sessions.backends.db import SessionStore
s = SessionStore(session_key='no-such-session-here')
s.save()
s.session_key
'ff882814010ccbc3c870523934fee5a2'
}}}
However, when I run this with Django 1.8.12, {{{s.session_key}}} actually
returns {{{None}}}.
The reason is that when the {{{SessionStore}}} instance is saved (with
{{{must_create=False}}}, i.e. the default), it results in a call to
{{{self.load()}}}, which looks for an existing Session object with the
given session_key. This of course does not yet exist, so the session_key
gets set to {{{None}}} - see
https://github.com/django/django/blob/1.8.12/django/contrib/sessions/backends/db.py#L29
I don't know if this change in behaviour was intentional or not, but I
didn't see any mention of it in the 1.7 or 1.8 release notes, and of
course the fact that the behaviour is different to what's documented
suggests it was not intentional. (I haven't checked the file's history,
but it definitely did work as documented in Django 1.6.)
In any case it's a pretty minor issue, only affecting one unit test of
mine, and was very easy to work around.
--
Ticket URL: <https://code.djangoproject.com/ticket/26503>
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/052.f6db33a8ba81da877ece4dd9af81ee37%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.