[config] properly use time type for options representing a time. stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 19 Apr 2010 13:38:46 +0200
branchstable
changeset 5326 0d9054eb3bd1
parent 5325 f1c660e1169e
child 5328 c51e8f62652a
child 5338 3e5a256d17ba
[config] properly use time type for options representing a time.
etwist/twconfig.py
misc/migration/3.7.4_Any.py
misc/migration/3.7.5_Any.py
server/serverconfig.py
server/sources/ldapuser.py
web/application.py
web/webconfig.py
--- a/etwist/twconfig.py	Mon Apr 19 13:37:32 2010 +0200
+++ b/etwist/twconfig.py	Mon Apr 19 13:38:46 2010 +0200
@@ -52,8 +52,8 @@
           'group': 'main', 'inputlevel': WebConfiguration.mode == 'system'
           }),
         ('session-time',
-         {'type' : 'int',
-          'default': 30*60,
+         {'type' : 'time',
+          'default': '30min',
           'help': 'session expiration time, default to 30 minutes',
           'group': 'main', 'inputlevel': 1,
           }),
--- a/misc/migration/3.7.4_Any.py	Mon Apr 19 13:37:32 2010 +0200
+++ b/misc/migration/3.7.4_Any.py	Mon Apr 19 13:38:46 2010 +0200
@@ -1,5 +1,1 @@
 sync_schema_props_perms('TrInfo', syncprops=False)
-
-config['http-session-time'] /= 60
-config['cleanup-session-time'] /= 60
-config['cleanup-anonymous-session-time'] /= 60
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/migration/3.7.5_Any.py	Mon Apr 19 13:38:46 2010 +0200
@@ -0,0 +1,4 @@
+if versions_map['cubicweb'][0] == (3, 7, 4):
+    config['http-session-time'] *= 60
+    config['cleanup-session-time'] *= 60
+    config['cleanup-anonymous-session-time'] *= 60
--- a/server/serverconfig.py	Mon Apr 19 13:37:32 2010 +0200
+++ b/server/serverconfig.py	Mon Apr 19 13:38:46 2010 +0200
@@ -109,8 +109,8 @@
           'group': 'main', 'inputlevel': (CubicWebConfiguration.mode == 'installed') and 0 or 1,
           }),
         ('session-time',
-         {'type' : 'int',
-          'default': 30*60,
+         {'type' : 'time',
+          'default': '30min',
           'help': 'session expiration time, default to 30 minutes',
           'group': 'main', 'inputlevel': 1,
           }),
--- a/server/sources/ldapuser.py	Mon Apr 19 13:37:32 2010 +0200
+++ b/server/sources/ldapuser.py	Mon Apr 19 13:38:46 2010 +0200
@@ -136,15 +136,15 @@
           }),
 
         ('synchronization-interval',
-         {'type' : 'int',
-          'default': 24*60*60,
+         {'type' : 'time',
+          'default': '1d',
           'help': 'interval between synchronization with the ldap \
 directory (default to once a day).',
           'group': 'ldap-source', 'inputlevel': 2,
           }),
         ('cache-life-time',
-         {'type' : 'int',
-          'default': 2*60,
+         {'type' : 'time',
+          'default': '2h',
           'help': 'life time of query cache in minutes (default to two hours).',
           'group': 'ldap-source', 'inputlevel': 2,
           }),
--- a/web/application.py	Mon Apr 19 13:37:32 2010 +0200
+++ b/web/application.py	Mon Apr 19 13:38:46 2010 +0200
@@ -35,12 +35,11 @@
         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:
--- a/web/webconfig.py	Mon Apr 19 13:37:32 2010 +0200
+++ b/web/webconfig.py	Mon Apr 19 13:38:46 2010 +0200
@@ -113,17 +113,17 @@
           'group': 'web', 'inputlevel': 2,
           }),
         ('http-session-time',
-         {'type' : 'int',
+         {'type' : 'time',
           'default': 0,
-          'help': "duration in minutes of the cookie used to store session "
-          "identifier. If 0, the cookie will expire when the user exist its "
-          "browser. Should be 0 or greater than repository\'s session-time.",
+          'help': "duration of the cookie used to store session identifier. "
+          "If 0, the cookie will expire when the user exist its browser. "
+          "Should be 0 or greater than repository\'s session-time.",
           'group': 'web', 'inputlevel': 2,
           }),
         ('cleanup-session-time',
-         {'type' : 'int',
-          'default': 1440,
-          'help': 'duration of inactivity in minutes after which a connection '
+         {'type' : 'time',
+          'default': '24h',
+          'help': 'duration of inactivity after which a connection '
           'will be closed, to limit memory consumption (avoid sessions that '
           'never expire and cause memory leak when http-session-time is 0). '
           'So even if http-session-time is 0 and the user don\'t close his '
@@ -132,8 +132,8 @@
           'group': 'web', 'inputlevel': 2,
           }),
         ('cleanup-anonymous-session-time',
-         {'type' : 'int',
-          'default': 5,
+         {'type' : 'time',
+          'default': '5min',
           'help': 'Same as cleanup-session-time but specific to anonymous '
           'sessions. You can have a much smaller timeout here since it will be '
           'transparent to the user. Default to 5min.',
@@ -331,7 +331,6 @@
                 files = [w.strip() for w in val.split(',') if w.strip()]
                 self.ext_resources[resource] = files
 
-
     # static files handling ###################################################
 
     @property