web/application.py
changeset 5328 c51e8f62652a
parent 5302 dfd147de06b2
parent 5326 0d9054eb3bd1
child 5385 b6e250dd7a7d
--- a/web/application.py	Mon Apr 19 13:51:16 2010 +0200
+++ b/web/application.py	Mon Apr 19 13:52:55 2010 +0200
@@ -38,14 +38,22 @@
         self.session_time = vreg.config['http-session-time'] or None
         if self.session_time is not None:
             assert self.session_time > 0
-            self.session_time *= 60 # convert minutes to seconds
             self.cleanup_session_time = self.session_time
         else:
-            self.cleanup_session_time = (vreg.config['cleanup-session-time'] or 1440) * 60
+            self.cleanup_session_time = vreg.config['cleanup-session-time'] or 1440 * 60
             assert self.cleanup_session_time > 0
-        self.cleanup_anon_session_time = (vreg.config['cleanup-anonymous-session-time'] or 5) * 60
+        self.cleanup_anon_session_time = vreg.config['cleanup-anonymous-session-time'] or 5 * 60
         assert self.cleanup_anon_session_time > 0
         self.authmanager = vreg['components'].select('authmanager', vreg=vreg)
+        if vreg.config.anonymous_user() is not None:
+            self.clean_sessions_interval = min(
+                5 * 60,
+                self.cleanup_session_time / 2.,
+                self.cleanup_anon_session_time / 2.)
+        else:
+            self.clean_sessions_interval = min(
+                5 * 60,
+                self.cleanup_session_time / 2.)
 
     def clean_sessions(self):
         """cleanup sessions which has not been unused since a given amount of
@@ -156,6 +164,10 @@
         global SESSION_MANAGER
         SESSION_MANAGER = self.session_manager
 
+    @property
+    def clean_sessions_interval(self):
+        return self.session_manager.clean_sessions_interval
+
     def clean_sessions(self):
         """cleanup sessions which has not been unused since a given amount of
         time