changeset 5418:ad132d9bd526

deal gracefully with cookie_lifetime/anonymous_session_lifetime upgrade issue
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 10 Jan 2010 19:48:49 +0100
parents f87dcdb71463
children 5eaec9412317
files MoinMoin/config/multiconfig.py docs/CHANGES
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Jan 10 18:29:50 2010 +0100
+++ b/MoinMoin/config/multiconfig.py	Sun Jan 10 19:48:49 2010 +0100
@@ -282,6 +282,32 @@
                      Please change it in your wiki configuration and try again."""
             raise error.ConfigurationError(msg)
 
+        # moin < 1.9 used cookie_lifetime = <float> (but converted it to int) for logged-in users and
+        # anonymous_session_lifetime = <float> or None for anon users
+        # moin >= 1.9 uses cookie_lifetime = (<float>, <float>) - first is anon, second is logged-in
+        if not (isinstance(self.cookie_lifetime, tuple) and len(self.cookie_lifetime) == 2):
+            logging.error("wiki configuration has an invalid setting: " +
+                          "cookie_lifetime = %r" % (self.cookie_lifetime, ))
+            try:
+                anon_lifetime = self.anonymous_session_lifetime
+                logging.warning("wiki configuration has an unsupported setting: " +
+                                "anonymous_session_lifetime = %r - " % anon_lifetime +
+                                "please remove it.")
+                if anon_lifetime is None:
+                    anon_lifetime = 0
+                anon_lifetime = float(anon_lifetime)
+            except:
+                # if anything goes wrong, use default value
+                anon_lifetime = 0
+            try:
+                logged_in_lifetime = int(self.cookie_lifetime)
+            except:
+                # if anything goes wrong, use default value
+                logged_in_lifetime = 12
+            self.cookie_lifetime = (anon_lifetime, logged_in_lifetime)
+            logging.warning("using cookie_lifetime = %r - " % (self.cookie_lifetime, ) +
+                            "please fix your wiki configuration.")
+
         self._loadPluginModule()
 
         # Preparse user dicts
--- a/docs/CHANGES	Sun Jan 10 18:29:50 2010 +0100
+++ b/docs/CHANGES	Sun Jan 10 19:48:49 2010 +0100
@@ -59,6 +59,9 @@
     external xapian index filters)
   * Fixed session cookie confusion for nested URL paths (like path=/ and
     path=/mywiki - for more info, see also "New features").
+  * handle cookie_lifetime / anonymous_session_lifetime upgrade issue
+    gracefully: emit errors/warnings to log, use old settings to create
+    cfg.cookie_lifetime as expected by moin 1.9.
 
   New features:
   * xmlrpc: added renamePage and deleteAttachment methods.