Ticket #8314: session-fix.diff
File session-fix.diff, 1.8 KB (added by , 16 years ago) |
---|
-
django/contrib/sessions/backends/base.py
173 173 delta = expiry - datetime.now() 174 174 return delta.days * 86400 + delta.seconds 175 175 176 def get_expiry_date(self ):176 def get_expiry_date(self, creating=False): 177 177 """Get session the expiry date (as a datetime object).""" 178 expiry = self.get('_session_expiry') 179 if isinstance(expiry, datetime): 180 return expiry 178 if creating: 179 expiry = None 180 else: 181 expiry = self.get('_session_expiry') 182 if isinstance(expiry, datetime): 183 return expiry 181 184 if not expiry: # Checks both None and 0 cases 182 185 expiry = settings.SESSION_COOKIE_AGE 183 186 return datetime.now() + timedelta(seconds=expiry) -
django/contrib/sessions/backends/db.py
47 47 create a *new* entry (as opposed to possibly updating an existing 48 48 entry). 49 49 """ 50 if must_create: 51 session_data = self.encode({}) 52 else: 53 session_data = self.encode(self._session) 50 54 obj = Session( 51 55 session_key = self.session_key, 52 session_data = se lf.encode(self._session),53 expire_date = self.get_expiry_date( )56 session_data = session_data, 57 expire_date = self.get_expiry_date(creating=True) 54 58 ) 55 59 sid = transaction.savepoint() 56 60 try: