Changeset 5375
- Timestamp:
- 05/28/07 08:02:16 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/newforms/forms.py
r5332 r5375 137 137 else: 138 138 help_text = u'' 139 output.append(normal_row % {'errors': bf_errors, 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text})139 output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text}) 140 140 if top_errors: 141 141 output.insert(0, error_row % top_errors) django/branches/unicode/django/newforms/util.py
r5310 r5375 1 1 from django.utils.html import escape 2 from django.utils.encoding import smart_unicode 2 from django.utils.encoding import smart_unicode, StrAndUnicode 3 3 4 4 def flatatt(attrs): … … 11 11 return u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()]) 12 12 13 class ErrorDict(dict ):13 class ErrorDict(dict, StrAndUnicode): 14 14 """ 15 15 A collection of errors that knows how to display itself in various formats. … … 17 17 The dictionary keys are the field names, and the values are the errors. 18 18 """ 19 def __ str__(self):19 def __unicode__(self): 20 20 return self.as_ul() 21 21 … … 27 27 return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u' * %s' % smart_unicode(i) for i in v])) for k, v in self.items()]) 28 28 29 class ErrorList(list ):29 class ErrorList(list, StrAndUnicode): 30 30 """ 31 31 A collection of errors that knows how to display itself in various formats. 32 32 """ 33 def __ str__(self):33 def __unicode__(self): 34 34 return self.as_ul() 35 35 django/branches/unicode/tests/regressiontests/forms/regressions.py
r5314 r5375 54 54 u'\u0448\u0442.' 55 55 56 Translated error messages used to be buggy. 57 >>> activate('ru') 58 >>> f = SomeForm({}) 59 >>> f.as_p() 60 u'<p><ul class="errorlist"><li>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.</li></ul></p>\n<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul>\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>' 61 >>> deactivate() 62 56 63 ####################### 57 64 # Miscellaneous Tests #
