[Mailman-Developers] Weird things happen after upgrade to 2.1a3+ CVS :-(

Barry A. Warsaw barry@zope.com
Mon, 22 Oct 2001 15:20:05 -0400


>>>>> "LM" == Luca Maranzano <liuk@publinet.it> writes:

    LM> just after upgrading to 2.1a3+ (latest CVS) it seems that
    LM> nothing is working any more. Python 2.0.1, email-0.93.

    LM> Here is an error message from gate_news and accessing to the
    LM> Web U/I works only for one list! I'll send the error log in
    LM> another message.

Darn, Dan Mick discovered the same problem triggered from
senddigests.  The problem is both scripts open the list unlocked, and
that breaks auto-upgrade of the schemas.  Attached is the patch I sent
Dan, and I /thought/ I checked in, but now see I didn't.

I will now though.  Can you give it a try?

    LM> Why make update said "nothing to do"? Are the config.pck files
    LM> changed after the modifications to the moderation process? Do
    LM> I have to convert them in some way?

No, you don't have to do anything.  Mailman should read both config.db
and config.pck and always write config.pck, so it should automatically
convert the first time it loads the list in a locked state.  Hitting
its web page or sending it an email should be all it takes.  Or even
running senddigest or gate_news the first time -- after application of
this patch...

-Barry

-------------------- snip snip --------------------
Index: MailList.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/MailList.py,v
retrieving revision 2.45
diff -u -r2.45 MailList.py
--- MailList.py	2001/10/21 06:32:36	2.45
+++ MailList.py	2001/10/22 19:18:57
@@ -535,18 +535,25 @@
     # Sanity checks
     #
     def CheckVersion(self, stored_state):
-        """Migrate prior version's state to new structure, if changed."""
-        if (self.data_version >= mm_cfg.DATA_FILE_VERSION and 
-                type(self.data_version) == type(mm_cfg.DATA_FILE_VERSION)):
+        """Auto-update schema if necessary."""
+        if self.data_version >= mm_cfg.DATA_FILE_VERSION:
             return
         else:
-            self.InitVars() # Init any new variables, 
-            self.Load(check_version = 0) # then reload the file
-            from versions import Update
-            Update(self, stored_state)
-            self.data_version = mm_cfg.DATA_FILE_VERSION
-        if self.Locked():
-            self.Save()
+            # Initialize any new variables
+            self.InitVars()
+            # Then reload the database (but don't recurse)
+            self.Load(check_version=0)
+            # We must hold the list lock in order to update the schema
+            waslocked = self.Locked()
+            self.Lock()
+            try:
+                from versions import Update
+                Update(self, stored_state)
+                self.data_version = mm_cfg.DATA_FILE_VERSION
+                self.Save()
+            finally:
+                if not waslocked:
+                    self.Unlock()
 
     def CheckValues(self):
         """Normalize selected values to known formats."""