bab9bb6b69
Create new directories: ceph config config-files filesystem kernel kernel/kernel-modules ldap logging strorage-drivers tools utilities virt Retire directories: connectivity core devtools support extended Delete two packages: tgt irqbalance Relocated packages: base/ dhcp initscripts libevent lighttpd linuxptp memcached net-snmp novnc ntp openssh pam procps sanlock shadow sudo systemd util-linux vim watchdog ceph/ python-cephclient config/ facter puppet-4.8.2 puppet-modules filesystem/ e2fsprogs nfs-utils nfscheck kernel/ kernel-std kernel-rt kernel/kernel-modules/ mlnx-ofa_kernel ldap/ nss-pam-ldapd openldap logging/ syslog-ng logrotate networking/ lldpd iproute mellanox python-ryu mlx4-config python/ python-2.7.5 python-django python-gunicorn python-setuptools python-smartpm python-voluptuous security/ shim-signed shim-unsigned tboot strorage-drivers/ python-3parclient python-lefthandclient virt/ cloud-init libvirt libvirt-python qemu tools/ storage-topology vm-topology utilities/ tis-extensions namespace-utils nova-utils update-motd Change-Id: I37ade764d873c701b35eac5881eb40412ba64a86 Story: 2002801 Task: 22687 Signed-off-by: Scott Little <scott.little@windriver.com>
74 lines
2.7 KiB
Diff
74 lines
2.7 KiB
Diff
---
|
|
django/contrib/sessions/backends/file.py | 29 +++++++++++++++++++----------
|
|
1 file changed, 19 insertions(+), 10 deletions(-)
|
|
|
|
--- a/django/contrib/sessions/backends/file.py
|
|
+++ b/django/contrib/sessions/backends/file.py
|
|
@@ -6,13 +6,14 @@ import shutil
|
|
import tempfile
|
|
|
|
from django.conf import settings
|
|
-from django.contrib.sessions.backends.base import SessionBase, CreateError, VALID_KEY_CHARS
|
|
-from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
|
|
+from django.contrib.sessions.backends.base import (
|
|
+ VALID_KEY_CHARS, CreateError, SessionBase,
|
|
+)
|
|
+from django.contrib.sessions.exceptions import InvalidSessionKey
|
|
+from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
|
|
from django.utils import timezone
|
|
from django.utils.encoding import force_text
|
|
|
|
-from django.contrib.sessions.exceptions import InvalidSessionKey
|
|
-
|
|
|
|
class SessionStore(SessionBase):
|
|
"""
|
|
@@ -70,6 +71,15 @@ class SessionStore(SessionBase):
|
|
modification = datetime.datetime.fromtimestamp(modification)
|
|
return modification
|
|
|
|
+ def _expiry_date(self, session_data):
|
|
+ """
|
|
+ Return the expiry time of the file storing the session's content.
|
|
+ """
|
|
+ expiry = session_data.get('_session_expiry')
|
|
+ if not expiry:
|
|
+ expiry = self._last_modification() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)
|
|
+ return expiry
|
|
+
|
|
def load(self):
|
|
session_data = {}
|
|
try:
|
|
@@ -88,15 +98,13 @@ class SessionStore(SessionBase):
|
|
self.create()
|
|
|
|
# Remove expired sessions.
|
|
- expiry_age = self.get_expiry_age(
|
|
- modification=self._last_modification(),
|
|
- expiry=session_data.get('_session_expiry'))
|
|
- if expiry_age < 0:
|
|
+ expiry_age = self.get_expiry_age(expiry=self._expiry_date(session_data))
|
|
+ if expiry_age <= 0:
|
|
session_data = {}
|
|
self.delete()
|
|
self.create()
|
|
except (IOError, SuspiciousOperation):
|
|
- self.create()
|
|
+ self._session_key = None
|
|
return session_data
|
|
|
|
def create(self):
|
|
@@ -107,10 +115,11 @@ class SessionStore(SessionBase):
|
|
except CreateError:
|
|
continue
|
|
self.modified = True
|
|
- self._session_cache = {}
|
|
return
|
|
|
|
def save(self, must_create=False):
|
|
+ if self.session_key is None:
|
|
+ return self.create()
|
|
# Get the session data now, before we start messing
|
|
# with the file it is stored within.
|
|
session_data = self._get_session(no_load=must_create)
|