diff options
| author | bwarsaw | 2002-04-11 04:25:31 +0000 |
|---|---|---|
| committer | bwarsaw | 2002-04-11 04:25:31 +0000 |
| commit | d9dff24ad9d11e765cacb2dfdb8a70cd9767b6b2 (patch) | |
| tree | 61c5d5a267bd4ae13219d49bdc2cde302952f7d9 | |
| parent | 749e9c7f3f2b49fe7ba2cc8ab0a585fb0cba0424 (diff) | |
| download | mailman-d9dff24ad9d11e765cacb2dfdb8a70cd9767b6b2.tar.gz mailman-d9dff24ad9d11e765cacb2dfdb8a70cd9767b6b2.tar.zst mailman-d9dff24ad9d11e765cacb2dfdb8a70cd9767b6b2.zip | |
_postValidate(): New method which is called after all the form
attributes have been processed. This allows for the gui component to
do sanity checks across inter-dependent values. Default is no-op.
handleForm(): We don't need the `tag' arguments to addError() since
the default is 'Error: '. Also, rearrange the exception logic so that
the _setValue() call happens in an else and the except clauses don't
need to return. This allows the gui component to still get a chance
at _postValidate(), even if there were errors.
| -rw-r--r-- | Mailman/Gui/GUIBase.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Mailman/Gui/GUIBase.py b/Mailman/Gui/GUIBase.py index 19098e894..44e6d3d82 100644 --- a/Mailman/Gui/GUIBase.py +++ b/Mailman/Gui/GUIBase.py @@ -110,6 +110,10 @@ class GUIBase: if not property.startswith('_') and getattr(mlist, property) <> val: setattr(mlist, property, val) + def _postValidate(self, mlist, doc): + # Validate all the attributes for this category + pass + def handleForm(self, mlist, category, subcat, cgidata, doc): for item in self.GetConfigInfo(mlist, category, subcat): # Skip descriptions and legacy non-attributes @@ -136,17 +140,17 @@ class GUIBase: try: val = self._getValidValue(mlist, property, wtype, val) except ValueError: - doc.addError(_('Invalid value for variable: %(property)s'), - tag=_('Error: ')) - return + doc.addError(_('Invalid value for variable: %(property)s')) # This is the parent of MMBadEmailError and MMHostileAddress except Errors.EmailAddressError: doc.addError( - _('Bad email address for option %(property)s: %(val)s'), - tag=_('Error: ')) - return - # Set the attribute, which will normally delegate to the mlist - self._setValue(mlist, property, val, doc) + _('Bad email address for option %(property)s: %(val)s')) + else: + # Set the attribute, which will normally delegate to the mlist + self._setValue(mlist, property, val, doc) + # Do a final sweep once all the attributes have been set. This is how + # we can do cross-attribute assertions + self._postValidate(mlist, doc) # Convenience method for handling $-string attributes def _convertString(self, mlist, property, alloweds, val, doc): |
