From 5fa3e15deeada360e7e0d0ef32818786d9c1bf0d Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Mon, 8 May 2000 22:15:15 +0000 Subject: Elaborations related to the new delivery stuff. Specifically, HoldMessage(): Take an optional msgdata dictionary, which gets stored along with all the other information related to this held message in the held message database. __handlepost(): Add some backwards compatibility code for pre 2.0b3 held message databases now that the held record can be 6 elements long (this should really not be a length-dependent tuple). Also, use HandlerAPI.DeliverToList() to send approved messages out, and check the return value to see if the message needs to be enqueued. --- Mailman/ListAdmin.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Mailman/ListAdmin.py b/Mailman/ListAdmin.py index afcbee2f1..8dbcc8abf 100644 --- a/Mailman/ListAdmin.py +++ b/Mailman/ListAdmin.py @@ -127,7 +127,7 @@ class ListAdmin: assert rtype == SUBSCRIPTION self.__handlesubscription(data, value, comment) - def HoldMessage(self, msg, reason): + def HoldMessage(self, msg, reason, msgdata={}): # assure that the database is open for writing self.__opendb() # get the next unique id @@ -153,13 +153,20 @@ class ListAdmin: # the message's subject # a string description of the problem # name of the file in $PREFIX/data containing the msg text + # an additional dictionary of message metadata # msgsubject = msg.get('subject', '(no subject)') - data = time.time(), sender, msgsubject, reason, filename + data = time.time(), sender, msgsubject, reason, filename, msgdata self.__db[id] = (HELDMSG, data) def __handlepost(self, record, value, comment): - ptime, sender, subject, reason, filename = record + # 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 path = os.path.join(mm_cfg.DATA_DIR, filename) rejection = None if value == 0: @@ -171,8 +178,10 @@ class ListAdmin: # and raise an exception. raise Errors.LostHeldMessage(path) msg = Message.Message(fp) - msg.approved = 1 - self.Post(msg) + msgdata['approved'] = 1 + enqueue = HandlerAPI.DeliverToList(self, msg, newdata=msgdata) + if enqueue: + msg.Enqueue(self, msgdata) elif value == 1: # Rejected rejection = 'Refused' -- cgit v1.3.1