#32088: Django Database Sessions - Can't Retrieve expire_date from
request.session
(SessionStore)
-------------------------------------+-------------------------------------
Reporter: Nate Pinchot | Owner: Pallav
| Parikh
Type: New feature | Status: assigned
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Nate Pinchot):
Replying to [comment:5 Pallav Parikh]:
> Let me know, if this looks okay, or any other suggestion.
>
I think this is a great concept to solve it. Thank you!
Can we amend the list of setting expire_date cases?
** setting expire_date cases:
* on every `save()` call, sets `expire_date` for current `SessionStore`
i.e `request.session` instance.
* set new `datetime` value: Valid
* set anything else except `datetime`: Invalid -> in this case, does't set
new value but preserves current `expire_date` value
* on every `load()` call, sets `expire_date` for current `SessionStore`
i.e `request.session` instance.
This additional case would set `expire_date` efficiently each time the
session is loaded, so an additional query isn't needed if the session
isn't being saved. Currently, for my case since the session is not being
saved, I would cause an additional query by referencing
`request.session.expire_date`.
I see the PR you created.
https://github.com/django/django/pull/13524/files#diff-
0804b404a59dd4551b51b9e62e5a6ca8R44
Perhaps this PR could also update the `load()` function to something
similar to below.
{{{#!python
def load(self):
s = self._get_session_from_db()
if s:
self._expire_date = s.expire_date
return self.decode(s.session_data)
return {}
}}}
I would have put the suggestion in the PR instead, but since we've been
conversing here and also because the `load()` function is currently
unchanged, I could not add a targeted comment on the PR. If it's
preferable for me to comment on the PR instead with code suggestions, let
me know :)
Let me know your thoughts on this?
--
Ticket URL: <https://code.djangoproject.com/ticket/32088#comment:9>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.0753a0fa329124feb980368d272939b4%40djangoproject.com.