From ac82295f250f93d3699b03c999d15013133ac474 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 26 Feb 2004 04:15:04 +0000 Subject: [PATCH] Missed checkin. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2122 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/sessions.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/roundup/backends/sessions.py b/roundup/backends/sessions.py index 60a1796..a0f3f50 100644 --- a/roundup/backends/sessions.py +++ b/roundup/backends/sessions.py @@ -1,4 +1,4 @@ -#$Id: sessions.py,v 1.8 2004-02-19 02:39:05 richard Exp $ +#$Id: sessions.py,v 1.9 2004-02-26 04:15:04 richard Exp $ """This module defines a very basic store that's used by the CGI interface to store session and one-time-key information. @@ -115,9 +115,23 @@ class BasicDatabase: def commit(self): pass + def updateTimestamp(self, sessid): + self.set(sessid, **{self.timestamp: time.time()}) + + def clean(self, now): + """Age sessions, remove when they haven't been used for a week. + """ + week = 60*60*24*7 + for sessid in self.list(): + interval = now - self.get(sessid, self.timestamp) + if interval > week: + self.destroy(sessid) + class Sessions(BasicDatabase): name = 'sessions' + timestamp = 'last_use' class OneTimeKeys(BasicDatabase): name = 'otks' + timestamp = '__time' -- 2.30.2