2011-12-12 14:43:37 +04:00
|
|
|
from django.template.defaultfilters import escape
|
|
|
|
|
2011-02-03 14:03:01 +03:00
|
|
|
class SimpleException(Exception):
|
|
|
|
" Exception extended with a value "
|
|
|
|
|
|
|
|
def __init__(self, value):
|
|
|
|
self.value = value
|
|
|
|
super(SimpleException, self).__init__()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return repr(self.value)
|
2011-12-12 14:43:37 +04:00
|
|
|
|
|
|
|
def parse_validation_messages(err):
|
|
|
|
error = ''
|
2011-12-13 16:11:10 +04:00
|
|
|
if not hasattr(err, 'message_dict'):
|
|
|
|
return str(err)
|
2011-12-12 14:43:37 +04:00
|
|
|
for field, msgs in err.message_dict.items():
|
|
|
|
error += ("%s: " % field)
|
|
|
|
for msg in msgs:
|
|
|
|
error += ("%s " % escape(msg))
|
|
|
|
return error
|