Python 3.6: Fixed issue with gravatar function
Hashing of string object doesn't work. Also added a deprecation warning that pillar.api.utils.gravatar should be used; pillar.web.utils.gravatar is just a copy.
This commit is contained in:
parent
dcdcd99393
commit
ae5009c9ef
@ -141,10 +141,10 @@ def str2id(document_id):
|
||||
raise wz_exceptions.BadRequest('Invalid object ID %r' % document_id)
|
||||
|
||||
|
||||
def gravatar(email, size=64):
|
||||
def gravatar(email: str, size=64):
|
||||
parameters = {'s': str(size), 'd': 'mm'}
|
||||
return "https://www.gravatar.com/avatar/" + \
|
||||
hashlib.md5(str(email)).hexdigest() + \
|
||||
hashlib.md5(email.encode()).hexdigest() + \
|
||||
"?" + urllib.parse.urlencode(parameters)
|
||||
|
||||
|
||||
|
@ -49,11 +49,13 @@ def attach_project_pictures(project, api):
|
||||
project.picture_header = get_file(project.picture_header, api=api)
|
||||
|
||||
|
||||
def gravatar(email, size=64):
|
||||
parameters = {'s': str(size), 'd': 'mm'}
|
||||
return "https://www.gravatar.com/avatar/" + \
|
||||
hashlib.md5(str(email)).hexdigest() + \
|
||||
"?" + urllib.parse.urlencode(parameters)
|
||||
def gravatar(email: str, size=64):
|
||||
import warnings
|
||||
warnings.warn("the pillar.web.gravatar function is deprecated; use hashlib instead",
|
||||
DeprecationWarning, 2)
|
||||
|
||||
from pillar.api.utils import gravatar as api_gravatar
|
||||
return api_gravatar(email, size)
|
||||
|
||||
|
||||
def datetime_now():
|
||||
|
Loading…
x
Reference in New Issue
Block a user