diff options
-rw-r--r-- | Mailman/Cgi/confirm.py | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/Mailman/Cgi/confirm.py b/Mailman/Cgi/confirm.py index 6cfda0f5..ff4d549f 100644 --- a/Mailman/Cgi/confirm.py +++ b/Mailman/Cgi/confirm.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2003 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2004 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -33,6 +33,12 @@ from Mailman.Logging.Syslog import syslog _ = i18n._ i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) +try: + True, False +except NameError: + True = 1 + False = 0 + def main(): @@ -95,7 +101,7 @@ def main(): Otherwise, <a href="%(confirmurl)s">re-enter</a> your confirmation string.''') - content = Pending.confirm(cookie, expunge=0) + content = mlist.pend_confirm(cookie, expunge=False) if content is None: bad_confirmation(doc, badconfirmstr) doc.AddItem(mlist.GetMailmanFooter()) @@ -122,8 +128,8 @@ def main(): doc.addError(_("""The address requesting unsubscription is not a member of the mailing list. Perhaps you have already been unsubscribed, e.g. by the list administrator?""")) - # And get rid of this confirmation cookie - Pending.confirm(cookie) + # Expunge this record from the pending database. + expunge(mlist, cookie) elif content[0] == Pending.CHANGE_OF_ADDRESS: if cgidata.getvalue('cancel'): addrchange_cancel(mlist, doc, cookie) @@ -138,7 +144,8 @@ def main(): doc.addError(_("""The address requesting to be changed has been subsequently unsubscribed. This request has been cancelled.""")) - Pending.confirm(cookie, expunge=1) + # Expunge this record from the pending database. + expunge(mlist, cookie) elif content[0] == Pending.HELD_MESSAGE: if cgidata.getvalue('cancel'): heldmsg_cancel(mlist, doc, cookie) @@ -170,6 +177,17 @@ def bad_confirmation(doc, extra=''): doc.AddItem(extra) +def expunge(mlist, cookie): + # Expunge this record from the list's pending database. This requires + # that the list lock be acquired, however the list doesn't need to be + # saved because this operation doesn't touch the config.pck file. + mlist.Lock() + try: + mlist.pend_confirm(cookie, expunge=True) + finally: + mlist.Unlock() + + def ask_for_cookie(mlist, doc, extra=''): title = _('Enter confirmation cookie') @@ -291,7 +309,7 @@ def subscription_prompt(mlist, doc, cookie, userdesc): def subscription_cancel(mlist, doc, cookie): # Discard this cookie - userdesc = Pending.confirm(cookie, expunge=1)[1] + userdesc = mlist.pend_confirm(cookie)[1] lang = userdesc.language i18n.set_language(lang) doc.set_language(lang) @@ -324,7 +342,7 @@ def subscription_confirm(mlist, doc, cookie, cgidata): digest = None else: digest = None - userdesc = Pending.confirm(cookie, expunge=0)[1] + userdesc = mlist.pend_confirm(cookie, expunge=False)[1] fullname = cgidata.getvalue('realname', None) if fullname is not None: fullname = Utils.canonstr(fullname, lang) @@ -379,8 +397,8 @@ def subscription_confirm(mlist, doc, cookie, cgidata): def unsubscription_cancel(mlist, doc, cookie): - # Discard this cookie - Pending.confirm(cookie, expunge=1) + # Expunge this record from the pending database + expunge(mlist, cookie) doc.AddItem(_('You have canceled your unsubscription request.')) @@ -397,7 +415,7 @@ def unsubscription_confirm(mlist, doc, cookie): try: # Do this in two steps so we can get the preferred language for # the user who is unsubscribing. - op, addr = Pending.confirm(cookie, expunge=0) + op, addr = mlist.pend_confirm(cookie, expunge=False) lang = mlist.getMemberLanguage(addr) i18n.set_language(lang) doc.set_language(lang) @@ -467,8 +485,8 @@ def unsubscription_prompt(mlist, doc, cookie, addr): def addrchange_cancel(mlist, doc, cookie): - # Discard this cookie - Pending.confirm(cookie, expunge=1) + # Expunge this record from the pending database + expunge(mlist, cookie) doc.AddItem(_('You have canceled your change of address request.')) @@ -485,7 +503,8 @@ def addrchange_confirm(mlist, doc, cookie): try: # Do this in two steps so we can get the preferred language for # the user who is unsubscribing. - op, oldaddr, newaddr, globally = Pending.confirm(cookie, expunge=0) + op, oldaddr, newaddr, globally = mlist.pend_confirm( + cookie, expunge=False) lang = mlist.getMemberLanguage(oldaddr) i18n.set_language(lang) doc.set_language(lang) @@ -565,14 +584,14 @@ def addrchange_prompt(mlist, doc, cookie, oldaddr, newaddr, globally): def heldmsg_cancel(mlist, doc, cookie): - # Discard this cookie title = _('Continue awaiting approval') doc.SetTitle(title) table = Table(border=0, width='100%') table.AddRow([Center(Bold(FontAttr(title, size='+1')))]) table.AddCellInfo(table.GetCurrentRowIndex(), 0, bgcolor=mm_cfg.WEB_HEADER_COLOR) - Pending.confirm(cookie, expunge=1) + # Expunge this record from the pending database. + expunge(mlist, cookie) table.AddRow([_('''Okay, the list moderator will still have the opportunity to approve or reject this message.''')]) doc.AddItem(table) @@ -591,7 +610,7 @@ def heldmsg_confirm(mlist, doc, cookie): try: # Do this in two steps so we can get the preferred language for # the user who posted the message. - op, id = Pending.confirm(cookie, expunge=1) + op, id = mlist.pend_confirm(cookie) ign, sender, msgsubject, ign, ign, ign = mlist.GetRecord(id) subject = Utils.websafe(msgsubject) lang = mlist.getMemberLanguage(sender) @@ -708,7 +727,7 @@ def reenable_confirm(mlist, doc, cookie): try: # Do this in two steps so we can get the preferred language for # the user who is unsubscribing. - op, listname, addr = Pending.confirm(cookie, expunge=0) + op, listname, addr = mlist.pend_confirm(cookie, expunge=False) lang = mlist.getMemberLanguage(addr) i18n.set_language(lang) doc.set_language(lang) |