Update of /cvsroot/mailman/mailman/Mailman/Cgi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16993

Modified Files:
      Tag: Release_2_1-maint
        confirm.py 
Log Message:
main(), subscription_cancel(), unsubscription_cancel(), addrchange_cancel()
addrchange_confirm(), heldmsg_cancel(), heldmsg_confirm(), reenable_confirm():
Convert to the new pending database interface.

expunge(): A helper function which ensures that the list is locked before
expunging an item from the confirmation database.


Index: confirm.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Cgi/confirm.py,v
retrieving revision 2.31.2.3
retrieving revision 2.31.2.4
diff -u -d -r2.31.2.3 -r2.31.2.4
--- confirm.py  1 Dec 2003 01:24:03 -0000       2.31.2.3
+++ confirm.py  10 Feb 2004 22:50:10 -0000      2.31.2.4
@@ -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 @@
 _ = i18n._
 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
 
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 
 def main():
@@ -95,7 +101,7 @@
     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 @@
                 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 @@
                     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 @@
     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_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 @@
                     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 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 @@
         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 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 @@
         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 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 @@
         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 @@
         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)


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to