summaryrefslogtreecommitdiff
path: root/Mailman/ListAdmin.py
diff options
context:
space:
mode:
authorbwarsaw2001-07-20 00:02:56 +0000
committerbwarsaw2001-07-20 00:02:56 +0000
commited3b6981731c3b1b6a3b76a757d08a0e9e7b4815 (patch)
tree7f791f2eeba3f7cd0c164bb2642a6ef427315d5d /Mailman/ListAdmin.py
parente62c9fe25aa797a431e36997e028a047e6aea8cb (diff)
downloadmailman-ed3b6981731c3b1b6a3b76a757d08a0e9e7b4815.tar.gz
mailman-ed3b6981731c3b1b6a3b76a757d08a0e9e7b4815.tar.zst
mailman-ed3b6981731c3b1b6a3b76a757d08a0e9e7b4815.zip
IGN: new global flag for the version number entry.
__opendb(): Automatically update the schema based on the 'version' entry (or lack thereof). Specifically, add a fullname field to any held SUBSCRIPTION entries, and a msgdata dictionary to any HELDMSG entries (but only if they don't have enough fields). This update is currently keyed off the lack of 'version' entry; after the update 'version' is set to REQUESTS_FILE_SCHEMA_VERSION. __closedb(): Set the 'version' entry to REQUESTS_FILE_SCHEMA_VERSION NumRequestsPending(): Subtract one from the length of the dictionary to account for the internal bookkeeping 'version' entry. __handlepost(): Remove the backwards compatibility hack for pre 2.0b3, since __opendb() now does this. HoldSubscription(): Accept a fullname field. __handlesubscription(): Unpack the fullname field.
Diffstat (limited to 'Mailman/ListAdmin.py')
-rw-r--r--Mailman/ListAdmin.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/Mailman/ListAdmin.py b/Mailman/ListAdmin.py
index e0624c8e4..4863742f8 100644
--- a/Mailman/ListAdmin.py
+++ b/Mailman/ListAdmin.py
@@ -41,6 +41,7 @@ from Mailman.pythonlib.StringIO import StringIO
from Mailman.i18n import _
# Request types requiring admin approval
+IGN = 0
HELDMSG = 1
SUBSCRIPTION = 2
@@ -76,12 +77,31 @@ class ListAdmin:
except IOError, e:
if e.errno <> errno.ENOENT: raise
self.__db = {}
+ # Migrate pre-2.1a3 held subscription records to include the
+ # fullname data field.
+ type, version = self.__db.get('version', (IGN, None))
+ if version is None:
+ # No previous revisiont number, must be upgrading to 2.1a3 or
+ # beyond from some unknown earlier version.
+ for id, (type, data) in self.__db.items():
+ if id == IGN:
+ pass
+ elif id == HELDMSG and len(data) == 5:
+ # tack on a msgdata dictionary
+ self.__db[id] = data + ({},)
+ elif id == SUBSCRIPTION and len(data) == 5:
+ # a fullname field was added
+ stime, addr, password, digest, lang = data
+ self.__db[id] = stime, addr, '', password, digest, lang
+
def __closedb(self):
if self.__db is not None:
assert self.Locked()
omask = os.umask(002)
try:
+ # Save the version number
+ self.__db['version'] = IGN, mm_cfg.REQUESTS_FILE_SCHEMA_VERSION
fp = open(self.__filename, 'w')
marshal.dump(self.__db, fp)
fp.close()
@@ -99,7 +119,8 @@ class ListAdmin:
def NumRequestsPending(self):
self.__opendb()
- return len(self.__db)
+ # Subtrace one for the version pseudo-entry
+ return len(self.__db) - 1
def __getmsgids(self, rtype):
self.__opendb()
@@ -177,12 +198,7 @@ class ListAdmin:
def __handlepost(self, record, value, comment, preserve, forward, addr):
# For backwards compatibility with pre 2.0beta3
- if len(record) == 5:
- ptime, sender, subject, reason, filename = record
- msgdata = {}
- else:
- # New format of record
- ptime, sender, subject, reason, filename, msgdata = record
+ ptime, sender, subject, reason, filename, msgdata = record
path = os.path.join(mm_cfg.DATA_DIR, filename)
# Handle message preservation
if preserve:
@@ -292,7 +308,7 @@ class ListAdmin:
return LOST
return status
- def HoldSubscription(self, addr, password, digest, lang):
+ def HoldSubscription(self, addr, fullname, password, digest, lang):
# assure that the database is open for writing
self.__opendb()
# get the next unique id
@@ -309,7 +325,7 @@ class ListAdmin:
# the digest flag
# the user's preferred language
#
- data = time.time(), addr, password, digest, lang
+ data = time.time(), addr, fullname, password, digest, lang
self.__db[id] = (SUBSCRIPTION, data)
#
# TBD: this really shouldn't go here but I'm not sure where else is
@@ -335,7 +351,7 @@ class ListAdmin:
msg.send(self, **{'tomoderators': 1})
def __handlesubscription(self, record, value, comment):
- stime, addr, password, digest, lang = record
+ stime, addr, fullname, password, digest, lang = record
if value == mm_cfg.DEFER:
return DEFER
elif value == mm_cfg.DISCARD: