From dd07bed2ad90cc6fe8672b46f080ac80271bb0cc Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Mon, 15 Nov 1999 22:29:46 +0000 Subject: PrintPostRequest(): Snarf the message text out of the file system instead of getting handed it from the requests database. If we can't open the file for reading, the message was lost, so print an information message and tidy up the housekeeping (this last is a bit of a kludge though). --- Mailman/Cgi/admindb.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py index cacef2872..b68578fd5 100644 --- a/Mailman/Cgi/admindb.py +++ b/Mailman/Cgi/admindb.py @@ -22,6 +22,7 @@ import os import string import types import cgi +from errno import ENOENT from Mailman import Utils, MailList, Errors from Mailman.htmlformat import * @@ -186,12 +187,28 @@ def PrintAddMemberRequest(mlist, id, table): ]) def PrintPostRequest(mlist, id, info, total, count, form): - ptime, sender, subject, reason, text = info + ptime, sender, subject, reason, filename = info form.AddItem('
') msg = 'Posting Held for Approval' if total <> 1: msg = msg + ' (%d of %d)' % (count, total) form.AddItem(Center(Header(2, msg))) + try: + fp = open(os.path.join(mm_cfg.DATA_DIR, filename)) + text = fp.read(mm_cfg.ADMINDB_PAGE_TEXT_LIMIT) + fp.close() + except IOError, (code, msg): + if code == ENOENT: + form.AddItem('Message with id #%d was lost.' % id) + form.AddItem('

') + # TBD: kludge to remove id from requests.db. value==2 means + # discard the message. + try: + mlist.HandleRequest(id, 2, None) + except Errors.LostHeldMessage: + pass + return + raise t = Table(cellspacing=0, cellpadding=0) t.AddRow([Bold('From:'), sender]) t.AddRow([Bold('Reason:'), reason]) @@ -212,7 +229,7 @@ def PrintPostRequest(mlist, id, info, total, count, form): ]) row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex() t.AddCellInfo(row, col, colspan=3) - t.AddRow([Bold('Full Text:'), + t.AddRow([Bold('Message Excerpt:'), TextArea('fulltext-%d' % id, text, rows=10, cols=60)]) row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex() t.AddCellInfo(row, col, colspan=3) @@ -241,7 +258,7 @@ def HandleRequests(mlist, doc, form): # handle the request id try: mlist.HandleRequest(request_id, v, comment) - except KeyError: + except (KeyError, Errors.LostHeldMessage): # that's okay, it just means someone else has already updated the # database, so just ignore this id continue -- cgit v1.3.1