summaryrefslogtreecommitdiff
path: root/Mailman/Gui/NonDigest.py
diff options
context:
space:
mode:
authorbwarsaw2002-02-27 00:07:37 +0000
committerbwarsaw2002-02-27 00:07:37 +0000
commitf2fa308e9145041962ac1677e96a06ae1fb31917 (patch)
tree4fabf89a453fc226fcdf51cbb287b5bef6dfd18a /Mailman/Gui/NonDigest.py
parentc0790a291e75737835035ad0960651acf4022e66 (diff)
downloadmailman-f2fa308e9145041962ac1677e96a06ae1fb31917.tar.gz
mailman-f2fa308e9145041962ac1677e96a06ae1fb31917.tar.zst
mailman-f2fa308e9145041962ac1677e96a06ae1fb31917.zip
Diffstat (limited to 'Mailman/Gui/NonDigest.py')
-rw-r--r--Mailman/Gui/NonDigest.py73
1 files changed, 16 insertions, 57 deletions
diff --git a/Mailman/Gui/NonDigest.py b/Mailman/Gui/NonDigest.py
index fe4722389..878b233ac 100644
--- a/Mailman/Gui/NonDigest.py
+++ b/Mailman/Gui/NonDigest.py
@@ -20,12 +20,16 @@
from Mailman import mm_cfg
from Mailman import Utils
from Mailman.i18n import _
+from Mailman.Gui.GUIBase import GUIBase
-BADJOINER = '</code>, <code>'
+from Mailman.Gui.Digest import ALLOWEDS
+PERSONALIZED_ALLOWEDS = ('user_address', 'user_delivered_to', 'user_password',
+ 'user_name', 'user_optionsurl',
+ )
-class NonDigest:
+class NonDigest(GUIBase):
def GetConfigCategory(self):
return 'nondigest', _('Non-digest&nbsp;options')
@@ -106,58 +110,13 @@ class NonDigest:
return info
- def HandleForm(self, mlist, cgidata, doc):
- for attr in ('msg_header', 'msg_footer'):
- handle_form(mlist, attr, cgidata, doc, 1)
-
-
-
-# This is code that can be shared between the digest and non-digest headers
-# and footers.
-def handle_form(mlist, attr, cgidata, doc, allow_personalizations):
- 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
- allows = ['real_name', 'list_name', 'host_name', 'web_page_url',
- 'description', 'info', 'cgiext', '_internal_name']
- if allow_personalizations and mlist.personalize:
- allows.extend(['user_address', 'user_delivered_to',
- 'user_password', 'user_name',
- 'user_optionsurl'])
- for allowed in allows:
- 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)
+ def _setValue(self, mlist, property, val, doc):
+ alloweds = list(ALLOWEDS)
+ if mlist.personalize:
+ alloweds.extend(PERSONALIZED_ALLOWEDS)
+ if property in ('msg_header', 'msg_footer'):
+ val = self._convertString(mlist, property, alloweds, val, doc)
+ if val is None:
+ # There was a problem, so don't set it
+ return
+ GUIBase._setValue(self, mlist, property, val, doc)