summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2001-07-11 20:03:31 +0000
committerbwarsaw2001-07-11 20:03:31 +0000
commitbf0ab6fe23bd1b733b54fde3521113db60168059 (patch)
tree1f5b4bd5d2b45550044cc5eae54b5935b3dfbdfa
parent6dd9faf4c0f217f3961c20593e80a97278c5aa33 (diff)
downloadmailman-bf0ab6fe23bd1b733b54fde3521113db60168059.tar.gz
mailman-bf0ab6fe23bd1b733b54fde3521113db60168059.tar.zst
mailman-bf0ab6fe23bd1b733b54fde3521113db60168059.zip
__NoMailCmdResponse => __noresponse
AddToResponse(): Use augmented assignment where appropriate. ParseMailCommands(): Set the __noresponse flag to 0 at the top of this method, so there's no chance that a previously handled command will mess up sending a response to this command. ProcessConfirmCmd(): Save the results from ProcessConfirmation() and check the operation in the first element. If it's a Pending.SUBSCRIPTION and the mailing list already sends out welcome messages, then don't send a "succeed" confirmation ourselves. Also, in the big except clause, catch MMNoSuchUserError which can happen if the user has made two unsub requests and confirmed them both (the second will trigger the exception). Do something more sensible than letting the exception trickle all the way back up. ;)
-rw-r--r--Mailman/MailCommandHandler.py49
1 files changed, 29 insertions, 20 deletions
diff --git a/Mailman/MailCommandHandler.py b/Mailman/MailCommandHandler.py
index 8008a0f3f..acb200dc7 100644
--- a/Mailman/MailCommandHandler.py
+++ b/Mailman/MailCommandHandler.py
@@ -27,10 +27,11 @@ import traceback
from mimelib.MsgReader import MsgReader
-from Mailman import Message
-from Mailman import Errors
from Mailman import mm_cfg
from Mailman import Utils
+from Mailman import Errors
+from Mailman import Message
+from Mailman import Pending
from Mailman.Logging.Syslog import syslog
from Mailman.pythonlib.StringIO import StringIO
import Mailman.i18n
@@ -124,9 +125,9 @@ class MailCommandHandler:
'options' : self.ProcessOptionsCmd,
'password' : self.ProcessPasswordCmd,
}
- self.__NoMailCmdResponse = 0
+ self.__noresponse = 0
- def AddToResponse(self, text, trunc=MAXCOLUMN, prefix=""):
+ def AddToResponse(self, text, trunc=MAXCOLUMN, prefix=''):
# Strip final newline
if text and text[-1] == '\n':
text = text[:-1]
@@ -134,13 +135,14 @@ class MailCommandHandler:
line = prefix + line
if trunc and len(line) > trunc:
line = line[:trunc-3] + '...'
- self.__respbuf = self.__respbuf + line + "\n"
+ self.__respbuf += line + '\n'
def AddError(self, text, prefix='>>>>> ', trunc=MAXCOLUMN):
self.__errors += 1
self.AddToResponse(text, trunc=trunc, prefix=prefix)
def ParseMailCommands(self, msg, msgdata):
+ self.__noresponse = 0
# Break any infloops. If this has come from a Mailman server then
# it'll have this header. It's still possible to infloop between two
# servers because there's no guaranteed way to know it came from a
@@ -291,7 +293,7 @@ MailCommandHandler.ParseMailCommands(). Here is the traceback:
responsemsg.send(self)
break
# send the response
- if not self.__NoMailCmdResponse:
+ if not self.__noresponse:
adminaddr = self.GetAdminEmail()
requestaddr = self.GetRequestEmail()
if self.__errors > 0:
@@ -325,7 +327,6 @@ The following is a detailed description of the problems.
responsemsg.send(self)
self.__respbuf = ''
self.__errors = 0
- self.__NoMailCmdResponse = 0
def ProcessPasswordCmd(self, args, cmd, mail):
if len(args) not in [0,2]:
@@ -645,7 +646,7 @@ background and instructions for subscribing to and using it, visit:
# the confirmation message that's been sent takes place
# of the results of the mail command message
#
- self.__NoMailCmdResponse = 1
+ self.__noresponse = 1
except Errors.MMNeedApproval:
adminemail = self.GetAdminEmail()
self.AddToResponse(_(
@@ -676,7 +677,7 @@ background and instructions for subscribing to and using it, visit:
# from the mailcommand handler.
#
if self.send_welcome_msg:
- self.__NoMailCmdResponse = 1
+ self.__noresponse = 1
else:
self.AddToResponse(_("Succeeded"))
@@ -686,7 +687,8 @@ background and instructions for subscribing to and using it, visit:
self.AddError(_("Usage: confirm <confirmation string>\n"))
return
try:
- self.ProcessConfirmation(args[0])
+ results = self.ProcessConfirmation(args[0])
+ op = results[0]
except Errors.MMBadConfirmation, e:
# Express in approximate days
days = int(mm_cfg.PENDING_REQUEST_LIFE / mm_cfg.days(1) + 0.5)
@@ -695,22 +697,29 @@ background and instructions for subscribing to and using it, visit:
strings expire approximately %(days)s days after the initial
subscription request. If your confirmation has expired,
please try to re-submit your subscription.'''),
- honor_leading_ws = 0),
+ honor_leading_ws=0),
trunc=0)
except Errors.MMNeedApproval, admin_addr:
- self.AddToResponse(_('''Your request has been forwarded to the
- list administrator for approval.'''))
+ self.AddToResponse(Utils.wrap(
+ _('''Your request has been forwarded to the
+ list administrator for approval.'''),
+ honor_leading_ws=0),
+ trunc=0)
except Errors.MMAlreadyAMember:
# Some other subscription request for this address has
# already succeeded.
- self.AddError(_("You are already subscribed."))
+ self.AddError(_('You are already subscribed.'))
+ except Errors.MMNoSuchUserError:
+ # They've already been unsubscribed
+ self.AddError(Utils.wrap(
+ _('''You are not a member. Have you already unsubscribed?'''),
+ honor_leading_ws=0),
+ trunc=0)
else:
- #
- # if the list sends a welcome message, we don't need a response
- # from the mailcommand handler.
- #
- if self.send_welcome_msg:
- self.__NoMailCmdResponse = 1
+ # Send the response unless this was a subscription confirmation,
+ # and the list sends a welcome message.
+ if op == Pending.SUBSCRIPTION and self.send_welcome_msg:
+ self.__noresponse = 1
else:
self.AddToResponse(_("Succeeded"))