summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mailman/versions.py59
1 files changed, 41 insertions, 18 deletions
diff --git a/Mailman/versions.py b/Mailman/versions.py
index 5327b09a5..35b0d9626 100644
--- a/Mailman/versions.py
+++ b/Mailman/versions.py
@@ -15,14 +15,13 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-"""Routines which rectify an old maillist with current maillist structure.
+"""Routines which rectify an old mailing list with current structure.
-The maillist .CheckVersion() method looks for an old .data_version
-setting in the loaded maillist structure, and if found calls the
-Update() routine from this module, supplying the list and the state
-last loaded from storage. (Th state is necessary to distinguish from
-default assignments done in the .InitVars() methods, before
-.CheckVersion() is called.)
+The MailList.CheckVersion() method looks for an old .data_version setting in
+the loaded structure, and if found calls the Update() routine from this
+module, supplying the list and the state last loaded from storage. The state
+is necessary to distinguish from default assignments done in the .InitVars()
+methods, before .CheckVersion() is called.
For new versions you should add sections to the UpdateOldVars() and the
UpdateOldUsers() sections, to preserve the sense of settings across
@@ -30,13 +29,18 @@ structural changes. Note that the routines have only one pass - when
.CheckVersions() finds a version change it runs this routine and then
updates the data_version number of the list, and then does a .Save(), so
the transformations won't be run again until another version change is
-detected."""
+detected.
+"""
-import re, string, types
+
+import re
+import string
+from types import ListType, StringType
import mm_cfg
import Utils
+
def Update(l, stored_state):
"Dispose of old vars and user options, mapping to new ones when suitable."
# No worry about entirely new vars because InitVars() takes care of them.
@@ -50,11 +54,13 @@ def UpdateOldVars(l, stored_state):
def PreferStored(oldname, newname, newdefault=uniqueval,
l=l, state=stored_state):
- """Use specified old value if new value does is not in stored state.
+ """Use specified old value if new value is not in stored state.
- If the old attr does not exist, and no newdefault is specified, the
- new attr is *not* created - so either specify a default or be
- positive that the old attr exists - or don't depend on the new attr."""
+ If the old attr does not exist, and no newdefault is specified, the
+ new attr is *not* created - so either specify a default or be positive
+ that the old attr exists - or don't depend on the new attr.
+
+ """
if hasattr(l, oldname):
if not state.has_key(newname):
setattr(l, newname, getattr(l, oldname))
@@ -106,12 +112,12 @@ def UpdateOldVars(l, stored_state):
# transfer the list data type for holding members and digest members
# to the dict data type starting file format version 11
#
- if type(l.members) is type([]):
+ if type(l.members) is ListType:
members = {}
for m in l.members:
members[m] = 1
l.members = members
- if type(l.digest_members) is type([]):
+ if type(l.digest_members) is ListType:
dmembers = {}
for dm in l.digest_members:
dmembers[dm] = 1
@@ -122,24 +128,41 @@ def UpdateOldVars(l, stored_state):
if not hasattr(l, "admin_notify_mchanges"):
setatrr(l, "admin_notify_mchanges",
mm_cfg.DEFAULT_ADMIN_NOTIFY_MCHANGES)
+ #
+ # Convert the members and digest_members addresses so that the keys of
+ # both these are always lowercased, but if there is a case difference, the
+ # value contains the case preserved value
+ #
for k in l.members.keys():
- if string.lower(k) != k:
+ if string.lower(k) <> k:
l.members[string.lower(k)] = Utils.LCDomain(k)
del l.members[k]
+ elif type(l.members[k]) == StringType and \
+ k == string.lower(l.members[k]):
+ # already converted
+ pass
else:
l.members[k] = 0
for k in l.digest_members.keys():
if string.lower(k) != k:
l.digest_members[string.lower(k)] = Utils.LCDomain(k)
del l.digest_members[k]
+ elif type(l.digest_members[k]) == StringType and \
+ k == string.lower(l.digest_members[k]):
+ # already converted
+ pass
else:
l.digest_members[k] = 0
def UpdateOldUsers(l):
"""Transform sense of changed user options."""
- # Currently nothing to do.
- pass
+ # pre-1.0b11 to 1.0b11. Force all keys in l.passwords to be lowercase
+ passwords = {}
+ for k, v in l.passwords.items():
+ passwords[string.lower(k)] = v
+ l.passwords = passwords
+
def older(version, reference):
"""True if version is older than current.