The disqus_export command raises an error if non-ascii characters are used.
gregmuellegger opened this issue · comments
Gregor Müllegger commented
This is the output of the command:
Exporting 3 comment(s)
Exporting comment 'Alain M. Lafon: Hiho,
you should check out the way you link on ...'
Exporting comment 'Alain M. Lafon: No links allowed? Well.. good to prevent spam, bad...'
Exporting comment 'Gregor Müllegger: You're right. I fixed it and the link should work ...'
Traceback (most recent call last):
File "bin/django", line 33, in <module>
djangorecipe.manage.main('website.settings')
File "/srv/gremu/eggs/djangorecipe-0.20-py2.5.egg/djangorecipe/manage.py", line 16, in main
management.execute_manager(mod)
File "/srv/gremu/parts/django/django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/srv/gremu/parts/django/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/srv/gremu/parts/django/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/srv/gremu/parts/django/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/management/commands/disqus_export.py", line 98, in handle
created_at=comment.submit_date.strftime('%Y-%m-%dT%H:%M'))
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/api.py", line 53, in call_method
return self.call(attr, **kwargs)
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/api.py", line 77, in call
request = self._get_request(url, self.METHODS[method], **params)
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/api.py", line 67, in _get_request
request = urllib2.Request(request_url, urlencode(params))
File "/usr/lib/python2.5/urllib.py", line 1250, in urlencode
v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 8: ordinal not in range(128)
A --dry-run
is working without any problems. The non ascii character is the
german "ü" in my last name.
Arthur commented
Hi Gregor,
I just fixed this issue in trunk. The problem was that the name was still a unicode string but should really be a byte string.
Could you try exporting comments with the current trunk revision and tell me if it works?
ilhan commented
Hi Arthurk,
same issue here, my database was latin1 but tried new clean database on utf-8 and still nothing.
EDIT
Seems like identifier and title needs encode('utf-8') before unicode() lines 112,113 in disqus_export.py