Changeset 5223
- Timestamp:
- 05/14/07 02:04:31 (1 year ago)
- Files:
-
- django/branches/unicode/django/db/models/base.py (modified) (1 diff)
- django/branches/unicode/django/newforms/util.py (modified) (2 diffs)
- django/branches/unicode/django/newforms/widgets.py (modified) (1 diff)
- django/branches/unicode/django/template/defaultfilters.py (modified) (3 diffs)
- django/branches/unicode/django/utils/html.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/db/models/base.py
r5203 r5223 85 85 86 86 def __repr__(self): 87 return smart_str(u'<%s: %s>' % (self.__class__.__name__, self))87 return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self))) 88 88 89 89 def __str__(self): django/branches/unicode/django/newforms/util.py
r4918 r5223 19 19 def as_ul(self): 20 20 if not self: return u'' 21 return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s%s</li>' % (k, v) for k, v in self.items()])21 return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s%s</li>' % (k, smart_unicode(v)) for k, v in self.items()]) 22 22 23 23 def as_text(self): 24 return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u' * %s' % ifor i in v])) for k, v in self.items()])24 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()]) 25 25 26 26 class ErrorList(list): … … 33 33 def as_ul(self): 34 34 if not self: return u'' 35 return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s</li>' % efor e in self])35 return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s</li>' % smart_unicode(e) for e in self]) 36 36 37 37 def as_text(self): 38 38 if not self: return u'' 39 return u'\n'.join([u'* %s' % efor e in self])39 return u'\n'.join([u'* %s' % smart_unicode(e) for e in self]) 40 40 41 41 class ValidationError(Exception): django/branches/unicode/django/newforms/widgets.py
r5126 r5223 254 254 def __unicode__(self): 255 255 "Outputs a <ul> for this set of radio fields." 256 return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % wfor w in self])256 return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % smart_unicode(w) for w in self]) 257 257 258 258 class RadioSelect(Select): django/branches/unicode/django/template/defaultfilters.py
r5081 r5223 171 171 "Escapes a value for use in a URL" 172 172 import urllib 173 return urllib.quote(value).decode('utf-8')173 return smart_unicode(urllib.quote(value)) 174 174 urlencode = stringfilter(urlencode) 175 175 … … 365 365 indent = u'\t' * tabs 366 366 if value[1]: 367 return u'%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, value[0], indent,367 return u'%s<li>%s\n%s<ul>\n%s\n%s</ul>\n%s</li>' % (indent, smart_unicode(value[0]), indent, 368 368 u'\n'.join([_helper(v, tabs+1) for v in value[1]]), indent, indent) 369 369 else: 370 return u'%s<li>%s</li>' % (indent, value[0])370 return u'%s<li>%s</li>' % (indent, smart_unicode(value[0])) 371 371 return _helper(value, 1) 372 372 … … 547 547 return pformat(value) 548 548 except Exception, e: 549 return u"Error in formatting:%s" % e549 return u"Error in formatting:%s" % smart_unicode(e) 550 550 551 551 # Syntax: register.filter(name of filter, callback) django/branches/unicode/django/utils/html.py
r5056 r5223 33 33 value = re.sub(r'\r\n|\r|\n', '\n', value) # normalize newlines 34 34 paras = re.split('\n{2,}', value) 35 paras = [ '<p>%s</p>' % p.strip().replace('\n', '<br />') for p in paras]35 paras = [u'<p>%s</p>' % p.strip().replace('\n', '<br />') for p in paras] 36 36 return u'\n\n'.join(paras) 37 37 … … 54 54 def urlize(text, trim_url_limit=None, nofollow=False): 55 55 """ 56 Converts any URLs in text into clickable links. Works on http://, https:// and 57 www. links. Links can have trailing punctuation (periods, commas, close-parens) 58 and leading punctuation (opening parens) and it'll still do the right thing. 56 Converts any URLs in text into clickable links. Works on http://, https:// 57 and www. links. Links can have trailing punctuation (periods, commas, 58 close-parens) and leading punctuation (opening parens) and it'll still do 59 the right thing. 59 60 60 61 If trim_url_limit is not None, the URLs in link text will be limited to 61 62 trim_url_limit characters. 62 63 63 If nofollow is True, the URLs in link text will get a rel="nofollow" attribute. 64 If nofollow is True, the URLs in link text will get a rel="nofollow" 65 attribute. 64 66 """ 65 67 trim_url = lambda x, limit=trim_url_limit: limit is not None and (x[:limit] + (len(x) >=limit and '...' or '')) or x
