diff options
| -rw-r--r-- | Mailman/Gui/Autoresponse.py | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/Mailman/Gui/Autoresponse.py b/Mailman/Gui/Autoresponse.py index 86909fca9..76e59f636 100644 --- a/Mailman/Gui/Autoresponse.py +++ b/Mailman/Gui/Autoresponse.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001 by the Free Software Foundation, Inc. +# Copyright (C) 2001,2002 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 @@ -17,8 +17,11 @@ """Administrative GUI for the autoresponder.""" from Mailman import mm_cfg +from Mailman import Utils from Mailman.i18n import _ +BADJOINER = '</code>, <code>' + class Autoresponse: @@ -34,14 +37,14 @@ class Autoresponse: _("""\ Auto-responder characteristics.<p> -In the text fields below, Python %(string)s interpolation is performed with +In the text fields below, string interpolation is performed with the following key/value substitutions: <p><ul> - <li><b>%(listname)s</b> - <em>gets the name of the mailing list</em> - <li><b>%(listurl)s</b> - <em>gets the list's listinfo URL</em> - <li><b>%(requestemail)s</b> - <em>gets the list's -request address</em> - <li><b>%(adminemail)s</b> - <em>gets the list's -admin address</em> - <li><b>%(owneremail)s</b> - <em>gets the list's -owner address</em> + <li><b>listname</b> - <em>gets the name of the mailing list</em> + <li><b>listurl</b> - <em>gets the list's listinfo URL</em> + <li><b>requestemail</b> - <em>gets the list's -request address</em> + <li><b>adminemail</b> - <em>gets the list's -admin address</em> + <li><b>owneremail</b> - <em>gets the list's -owner address</em> </ul> <p>For each text field, you can either enter the text directly into the text @@ -80,3 +83,49 @@ box, or you can specify a file on your local system to upload as the text."""), (or negative) for no grace period (i.e. auto-respond to every message).''')), ] + + def HandleForm(self, mlist, cgidata, doc): + # BAW: Refactor w/ similar code in NonDigest.py and Digest.py + for attr in ('autoresponse_postings_text', 'autoresponse_admin_text', + 'autoresponse_request_text'): + newval = cgidata.getvalue(attr) + # Are we converted to using $-strings? + dollarp = getattr(mlist, 'use_dollar_strings', 0) + if dollarp: + ids = Utils.dollar_identifiers(newval) + else: + # %-strings + ids = Utils.percent_identifiers(newval) + # Here's the list of allowable interpolations + for allowed in ['listname', 'listurl', 'requestemail', + 'adminemail', 'owneremail']: + if ids.has_key(allowed): + del ids[allowed] + if ids: + # What's left are not allowed + badkeys = ids.keys() + badkeys.sort() + bad = BADJOINER.join(badkeys) + doc.addError(_( + """The following illegal interpolation variables were + found in the <code>%(attr)s</code> string: + <code>%(bad)s</code> + <p>Your changes will be discarded. Please correct the + mistakes and try again."""), + tag=_('Error: ')) + return + # Now if we're still using %-strings, do a roundtrip conversion + # and see if the converted value is the same as the new value. If + # not, then they probably left off a trailing `s'. We'll warn + # them and use the corrected string. + if not dollarp: + fixed = Utils.to_percent(Utils.to_dollar(newval)) + if fixed <> newval: + doc.addError(_( + """Your <code>%(attr)s</code> string appeared to have + some correctable problems in its new value. The fixed + value will be used instead. Please double check that + this is what you intended. + """)) + newval = fixed + setattr(mlist, attr, newval) |
