Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Japanese characters can't be exported from member list #38

Closed
U-238 opened this issue Nov 2, 2012 · 3 comments
Closed

Japanese characters can't be exported from member list #38

U-238 opened this issue Nov 2, 2012 · 3 comments

Comments

@U-238
Copy link
Contributor

U-238 commented Nov 2, 2012

Description of problem:
Names containing non-ASCII characters cause an error when trying to export

Location of problem:
https://my.robogals.org/chapters/tokyo/edit/users/export/?status=1

Traceback (most recent call last):

File "/usr/local/django1.3.1/django/core/handlers/base.py", line 111, in get_response
response = callback(request, _callback_args, *_callback_kwargs)

File "/home/myrobogals/robogals/myrobogals/auth/decorators.py", line 78, in call
return self.view_func(request, _args, *_kwargs)

File "/home/myrobogals/robogals/myrobogals/rgprofile/views.py", line 1080, in exportusers
writer.writerow([user['user__username'], user['user__first_name'], user['user__last_name'], user['user__email'], user['user__mobile'], user['user__course'], user['user__university__name'], user['user__student_number'], user['user__alt_email'], user['user__date_joined'], user['user__dob'], user['user__gender'], user['user__uni_start'], user['user__uni_end'], user['user__course_type'], user['user__student_type']])

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

<WSGIRequest
GET:<QueryDict: {u'status': [u'1']}>,
POST:<QueryDict: {}>,
COOKIES:{'__utma': '225450521.1214822885.1351063476.1351063476.1351063476.1',
'__utmb': '225450521.1.10.1351063476',
'__utmc': '225450521',
'__utmz': '225450521.1351063476.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
'sessionid': '75f9db292eaeccbe4e6336c647812d33'},
META:{'DOCUMENT_ROOT': '/home/myrobogals/blank/',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTPS': '1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-us',
'HTTP_CONNECTION': 'keep-alive',
'HTTP_COOKIE': 'sessionid=75f9db292eaeccbe4e6336c647812d33; __utma=225450521.1214822885.1351063476.1351063476.1351063476.1; __utmb=225450521.1.10.1351063476; __utmc=225450521; __utmz=225450521.1351063476.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
'HTTP_HOST': 'my.robogals.org',
'HTTP_PROXY_CONNECTION': 'keep-alive',
'HTTP_REFERER': 'https://my.robogals.org/chapters/tokyo/edit/users/',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14',
'PATH_INFO': u'/chapters/tokyo/edit/users/export/',
'PATH_TRANSLATED': '/home/myrobogals/robogals/wsgi/myrobogals.wsgi/chapters/tokyo/edit/users/export/',
'QUERY_STRING': 'status=1',
'REMOTE_ADDR': '131.112.125.216',
'REMOTE_PORT': '38353',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/chapters/tokyo/edit/users/export/?status=1',
'SCRIPT_FILENAME': '/home/myrobogals/robogals/wsgi/myrobogals.wsgi',
'SCRIPT_NAME': u'',
'SERVER_ADDR': '10.1.1.220',
'SERVER_ADMIN': 'my@robogals.org',
'SERVER_NAME': 'my.robogals.org',
'SERVER_PORT': '443',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '

Apache/2.2.9 (Debian) Phusion_Passenger/2.2.11 PHP/5.3.6-13 with Suhosin-Patch mod_ruby/1.2.6 Ruby/1.8.7(2011-02-18) mod_ssl/2.2.9 OpenSSL/0.9.8o mod_wsgi/3.3 Python/2.6.6 mod_perl/2.0.5 Perl/v5.14.2 Server at my.robogals.org Port 443\n',
'SERVER_SOFTWARE': 'Apache/2.2.9 (Debian) Phusion_Passenger/2.2.11 PHP/5.3.6-13 with Suhosin-Patch mod_ruby/1.2.6 Ruby/1.8.7(2011-02-18) mod_ssl/2.2.9 OpenSSL/0.9.8o mod_wsgi/3.3 Python/2.6.6 mod_perl/2.0.5 Perl/v5.14.2',
'mod_wsgi.application_group': 'my.robogals.org|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '443',
'mod_wsgi.process_group': '',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 3),
'wsgi.errors': <mod_wsgi.Log object at 0xa4b62c8>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0xa3ca770>,
'wsgi.input': <mod_wsgi.Input object at 0xa4537c8>,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'https',
'wsgi.version': (1, 1)}>

@yfcheung
Copy link
Contributor

yfcheung commented Nov 3, 2012

The solution seems a bit illusional.

I saw some posts with the following comment regarding the solution:
"Like the stars in the sky, seems so close, until I actually want to reach it by rising my arm!"

I will keep looking.

@U-238
Copy link
Contributor Author

U-238 commented Nov 3, 2012

Using this error message from above I think the problem is with unicode characters:
"UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)"

Some things I found online about using CSV files with unicode output.
http://docs.python.org/2/library/csv.html#csv-examples
http://stackoverflow.com/questions/5838605/python-dictwriter-writing-utf-8-encoded-csv-files

Hopefully that helps

@U-238
Copy link
Contributor Author

U-238 commented Nov 16, 2012

Merged and tested!

@U-238 U-238 closed this as completed Nov 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants