Simplified the newforms error_messages setting code from [6625]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6785 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-12-01 16:50:48 +00:00
parent f27365e5bd
commit 394807866d
1 changed files with 7 additions and 13 deletions

View File

@ -83,21 +83,15 @@ class Field(object):
self.creation_counter = Field.creation_counter
Field.creation_counter += 1
self.error_messages = self._build_error_messages(error_messages)
def _build_error_messages(self, extra_error_messages):
error_messages = {}
def get_default_error_messages(klass):
def set_class_error_messages(messages, klass):
for base_class in klass.__bases__:
get_default_error_messages(base_class)
if hasattr(klass, 'default_error_messages'):
error_messages.update(klass.default_error_messages)
set_class_error_messages(messages, base_class)
messages.update(getattr(klass, 'default_error_messages', {}))
get_default_error_messages(self.__class__)
if extra_error_messages:
error_messages.update(extra_error_messages)
return error_messages
messages = {}
set_class_error_messages(messages, self.__class__)
messages.update(error_messages or {})
self.error_messages = messages
def clean(self, value):
"""