summaryrefslogtreecommitdiff
path: root/django/newforms/forms.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-06-07 21:49:06 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-06-07 21:49:06 +0000
commitd34639b09bf85dfb1b6f9a4b59f8ccbc3117230b (patch)
tree619db1e6fde32bbfb0c135bde382d1b1df395e9a /django/newforms/forms.py
parent659d99b7afda730180e80ea4d68a7d505b21ba86 (diff)
newforms-admin: Merged to [5439]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/newforms/forms.py')
-rw-r--r--django/newforms/forms.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py
index 952530bbd5..902ad616ed 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):
"""
@@ -189,11 +189,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():
@@ -206,16 +206,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):
"""