wagtail-deprecated / wagtaildemo

Old example site implemented with Wagtail. Please see https://github.com/wagtail/bakerydemo for the current demo site
http://wagtail.io
BSD 3-Clause "New" or "Revised" License
285 stars 144 forks source link

Unicode-objects must be encoded before hashing #78

Closed SalahAdDin closed 9 years ago

SalahAdDin commented 9 years ago

Hi guys, i'm testing my site and i find a issue with the ical export function:

Traceback:
File "/media/tulipan/Datos/Proyectos/Trabajo/CCCT/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/media/tulipan/Datos/Proyectos/Trabajo/CCCT/lib/python3.4/site-packages/wagtail/wagtailcore/views.py" in serve
  25.     return page.serve(request, *args, **kwargs)
File "/media/tulipan/Datos/Proyectos/Trabajo/CCCT/ccct/core/models.py" in serve
  769.                     export_event(self, 'ical'),
File "/media/tulipan/Datos/Proyectos/Trabajo/CCCT/ccct/core/utils.py" in export_event
  57.         uid = hashlib.sha1(event.url + str(start_datetime)).hexdigest() + '@ccct'

Exception Type: TypeError at /eventos/segunda-version-de-la-pagina/
Exception Value: Unicode-objects must be encoded before hashing

Can anyone help me with this?

gasman commented 9 years ago

Could you try changing line 57 of utils.py to:

uid = hashlib.sha1((event.url + str(start_datetime)).encode('utf-8')).hexdigest() + '@ccct'
SalahAdDin commented 9 years ago

@gasman only works these:

uid = hashlib.sha1(event.url.encode('utf-8') + str(start_datetime).encode('utf-8')).hexdigest() + '@ccct'
gasman commented 9 years ago

Thanks! I've updated the code in 9ff314c9481605e174769416dec1b71e16936b83.