Permalink
Browse files

Supress top-level validator messages if they also apply messages to c…

…ompound widget children.
  • Loading branch information...
amol- authored and ralphbean committed Mar 28, 2012
1 parent 06ac1b3 commit c144b01f3dd6d4b3e9a61da5e647fd9946c2e11c
Showing with 10 additions and 1 deletion.
  1. +10 −1 tw2/core/widgets.py
@@ -629,6 +629,9 @@ def _validate(self, value, state=None):
data[c.key] = vd.Invalid
any_errors = True
# Validate self, usually a CompoundValidator or a FormEncode form-level
# validator.
any_child_errors = False
if self.validator:
try:
data = self.validator.to_python(data)
@@ -642,7 +645,13 @@ def _validate(self, value, state=None):
if getattr(c, 'key', None) in error_dict:
c.error_msg = error_dict[c.key]
data[c.key] = vd.Invalid
raise
any_child_errors = True
any_errors = True
# Only re-raise this top-level exception if the validation error
# doesn't pertain to any of our children.
if not any_child_errors:
raise
if any_errors:
raise vd.ValidationError('childerror', self.validator)

0 comments on commit c144b01

Please sign in to comment.