summaryrefslogtreecommitdiff
path: root/django/forms/util.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2010-01-05 03:56:19 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2010-01-05 03:56:19 +0000
commit471596fc1afcb9c6258d317c619eaf5fd394e797 (patch)
tree193767161be3cc23dc2e6be5e4f16d8fd21a2925 /django/forms/util.py
parent4e89105d64bb9e04c409139a41e9c7aac263df4c (diff)
Merged soc2009/model-validation to trunk. Thanks, Honza!
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/util.py')
-rw-r--r--django/forms/util.py24
1 files changed, 5 insertions, 19 deletions
diff --git a/django/forms/util.py b/django/forms/util.py
index b9b88a61e6..1a1d823495 100644
--- a/django/forms/util.py
+++ b/django/forms/util.py
@@ -1,7 +1,11 @@
from django.utils.html import conditional_escape
-from django.utils.encoding import smart_unicode, StrAndUnicode, force_unicode
+from django.utils.encoding import StrAndUnicode, force_unicode
from django.utils.safestring import mark_safe
+# Import ValidationError so that it can be imported from this
+# module to maintain backwards compatibility.
+from django.core.exceptions import ValidationError
+
def flatatt(attrs):
"""
Convert a dictionary of attributes to a single string.
@@ -48,21 +52,3 @@ class ErrorList(list, StrAndUnicode):
def __repr__(self):
return repr([force_unicode(e) for e in self])
-class ValidationError(Exception):
- def __init__(self, message):
- """
- ValidationError can be passed any object that can be printed (usually
- a string) or a list of objects.
- """
- if isinstance(message, list):
- self.messages = ErrorList([smart_unicode(msg) for msg in message])
- else:
- message = smart_unicode(message)
- self.messages = ErrorList([message])
-
- def __str__(self):
- # This is needed because, without a __str__(), printing an exception
- # instance would result in this:
- # AttributeError: ValidationError instance has no attribute 'args'
- # See http://www.python.org/doc/current/tut/node10.html#handling
- return repr(self.messages)