Permalink
Browse files

Handle unspecified childerror case uncovered by latest test.

  • Loading branch information...
ralphbean committed Mar 29, 2012
1 parent 74dd870 commit e94c8034173c461074f4d2364d32f8f3dc3ee871
Showing with 7 additions and 0 deletions.
  1. +7 −0 tw2/core/validation.py
@@ -52,10 +52,17 @@ def __init__(self, msg, validator=None, widget=None):
mw = core.request_local().get('middleware')
if isinstance(validator, Validator):
msg = validator.msg_rewrites.get(msg, msg)
if mw and msg in mw.config.validator_msgs:
msg = mw.config.validator_msgs[msg]
elif hasattr(validator, 'msgs') and msg in validator.msgs:
msg = validator.msgs.get(msg, msg)
# In the event that the user specified a form-wide validator but
# they did not specify a childerror message, show no error.
if msg == 'childerror':
msg = ''
msg = re.sub('\$(\w+)',
lambda m: str(getattr(validator, m.group(1))), unicode(msg))
super(ValidationError, self).__init__(msg)

0 comments on commit e94c803

Please sign in to comment.