Mercurial > kallithea
changeset 1101:c1080b42a7cb beta
fixed problem with int. chars in gravatars
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 27 Feb 2011 03:18:23 +0100 |
parents | e7d7f05217c1 |
children | 8d0858376163 |
files | rhodecode/lib/helpers.py |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Sun Feb 27 02:43:44 2011 +0100 +++ b/rhodecode/lib/helpers.py Sun Feb 27 03:18:23 2011 +0100 @@ -6,12 +6,12 @@ import random import hashlib import StringIO +import urllib + from pygments.formatters import HtmlFormatter from pygments import highlight as code_highlight -from pylons import url +from pylons import url, request from pylons.i18n.translation import _, ungettext -from vcs.utils.annotate import annotate_highlight -from rhodecode.lib.utils import repo_name_slug from webhelpers.html import literal, HTML, escape from webhelpers.html.tools import * @@ -33,6 +33,9 @@ from webhelpers.html.tags import _set_input_attrs, _set_id_attr, \ convert_boolean_attrs, NotGiven +from vcs.utils.annotate import annotate_highlight +from rhodecode.lib.utils import repo_name_slug + def _reset(name, value=None, id=NotGiven, type="reset", **attrs): """Reset button """ @@ -557,9 +560,6 @@ #============================================================================== # GRAVATAR URL #============================================================================== -import hashlib -import urllib -from pylons import request def gravatar_url(email_address, size=30): ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme') @@ -568,7 +568,9 @@ baseurl_ssl = "https://secure.gravatar.com/avatar/" baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl - + if isinstance(email_address, unicode): + #hashlib crashes on unicode items + email_address = email_address.encode('utf8', 'replace') # construct the url gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?" gravatar_url += urllib.urlencode({'d':default, 's':str(size)})