[Mailman-Developers] Problem while upgrade to mailman 2.1 alpha

Barry A. Warsaw barry@zope.com
Sat, 9 Mar 2002 12:34:05 -0500


>>>>> "DO" == Dan Ohnesorg <dan@ohnesorg.cz> writes:

    DO> I am also triing to upgrade to never version and I have this
    DO> troubles:

    DO> Mailman.Errors.NotAMemberError: fickman@atlas.cz

    DO> and it is alo true, that this user is listed only in section

    |     'user_options': {   '3zsmost@schoolnet.cz': 8,
    |                         'fickman@atlas.cz': 8,

    DO> of dump_db.

    DO> Sure, the database is corrupt, but it is not fatal, i think
    DO> the upgrage should run OK.

I don't remember why, but I think it is possible in MM2.0.something
for an address to get stuck in user_options but not be in members or
digest_members.  Here's a patch that I think I'm going to check in
that does two things:

- it puts a membership check for the keys in usr_options and if that
  fails, it removes the key from user_options.

- it sets a `fence' in the list's attributes so that once
  CanonicalizeUserOptions() has been run on a list, it won't be run
  again.

Comments are welcome,
-Barry

Index: versions.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/versions.py,v
retrieving revision 2.21
diff -u -r2.21 versions.py
--- versions.py	7 Mar 2002 22:24:03 -0000	2.21
+++ versions.py	9 Mar 2002 17:32:42 -0000
@@ -329,6 +329,10 @@
 
 def CanonicalizeUserOptions(l):
     """Fix up the user options."""
+    # I want to put a flag in the list database which tells this routine to
+    # never try to canonicalize the user options again.
+    if getattr(l, 'useropts_version', 0) > 0:
+        return
     # pre 1.0rc2 to 1.0rc3.  For all keys in l.user_options to be lowercase,
     # but merge options for both cases
     options = {}
@@ -346,10 +350,15 @@
     # get/setDeilveryStatus().  This must be done after the addresses are
     # canonicalized.
     for k, v in l.user_options.items():
+        if not l.isMember(k):
+            # There's a key in user_options that isn't associated with a real
+            # member address.  This is likely caused by an earlier bug.
+            del l.user_options[k]
         if l.getMemberOption(k, mm_cfg.DisableDelivery):
             # Convert this flag into a legacy disable
             l.setDeliveryStatus(k, UNKNOWN)
             l.setMemberOption(k, mm_cfg.DisableDelivery, 0)
+    l.useropts_version = 1