diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-29 13:09:48 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-29 13:09:48 +0000 |
| commit | ddae2ecfe42a4135850a435e1eefc79dfecaa062 (patch) | |
| tree | d6d1e432938cf2fa3594264a7ca287c465e5b201 /django/newforms | |
| parent | fa1a0532d35ee5ff342c19821ad290ad48771aa4 (diff) | |
unicode: Merged from trunk up to [5380].
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5381 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/newforms')
| -rw-r--r-- | django/newforms/forms.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 649c015d72..7dd40b60aa 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -63,7 +63,7 @@ class BaseForm(StrAndUnicode): self.auto_id = auto_id self.prefix = prefix self.initial = initial or {} - self.__errors = None # Stores the errors after clean() has been called. + self._errors = None # Stores the errors after clean() has been called. # The base_fields class attribute is the *class-wide* definition of # fields. Because a particular *instance* of the class might want to @@ -87,12 +87,12 @@ class BaseForm(StrAndUnicode): raise KeyError('Key %r not found in Form' % name) return BoundField(self, field, name) - def _errors(self): + def _get_errors(self): "Returns an ErrorDict for self.data" - if self.__errors is None: + if self._errors is None: self.full_clean() - return self.__errors - errors = property(_errors) + return self._errors + errors = property(_get_errors) def is_valid(self): """ @@ -171,11 +171,11 @@ class BaseForm(StrAndUnicode): def full_clean(self): """ - Cleans all of self.data and populates self.__errors and self.cleaned_data. + Cleans all of self.data and populates self._errors and + self.cleaned_data. """ - errors = ErrorDict() + self._errors = ErrorDict() if not self.is_bound: # Stop further processing. - self.__errors = errors return self.cleaned_data = {} for name, field in self.fields.items(): @@ -188,16 +188,17 @@ class BaseForm(StrAndUnicode): self.cleaned_data[name] = value if hasattr(self, 'clean_%s' % name): value = getattr(self, 'clean_%s' % name)() - self.cleaned_data[name] = value + self.cleaned_data[name] = value except ValidationError, e: - errors[name] = e.messages + self._errors[name] = e.messages + if name in self.cleaned_data: + del self.cleaned_data[name] try: self.cleaned_data = self.clean() except ValidationError, e: - errors[NON_FIELD_ERRORS] = e.messages - if errors: + self._errors[NON_FIELD_ERRORS] = e.messages + if self._errors: delattr(self, 'cleaned_data') - self.__errors = errors def clean(self): """ |
