#32088: Django Database Sessions - Can't Retrieve expire_date from
request.session
(SessionStore)
-------------------------------------+-------------------------------------
Reporter: Nate Pinchot | Owner: Pallav
| Parikh
Type: New feature | Status: closed
Component: contrib.sessions | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* status: assigned => closed
* resolution: => wontfix
Comment:
Hi Nate.
I'm struggling to see the use-case here.
Sessions already expose methods to get and set the expiry, and these work
perfectly well with DB backend:
{{{
>>> import datetime
>>> from django.contrib.sessions.backends.db import SessionStore
>>> session = SessionStore('some_session_key')
>>> session.get_expiry_date()
datetime.datetime(2020, 10, 27, 9, 2, 7, 300236, tzinfo=<UTC>)
>>> # Bump the expiry date. We could use any base date, but let's choose
the existing session expiry:
>>> session.set_expiry(session.get_expiry_date() + datetime.timedelta(7))
>>> session.get_expiry_date()
datetime.datetime(2020, 11, 3, 9, 10, 43, 930981, tzinfo=<UTC>)
>>> # Session will be saved with new expiry:
>>> session.modified
True
}}}
The example you link to has been in the docs since the very beginning
21c4526557fb50b9b62f32065c7d3952ea35c5df — accessing the saved date on the
model isn't really something you need to do — it's sole purpose is to act
as an invalidator in the `get()` call.
You'd be welcome to add extra code to a subclass but I can't see that it's
something that we'd want to add to the code itself.
Perhaps I'm missing something but I think we need to say `wontfix` here.
--
Ticket URL: <https://code.djangoproject.com/ticket/32088#comment:11>
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.4dacde811251de46e8c9a5102874f1ac%40djangoproject.com.