Opened 11 years ago

Closed 10 years ago

#791 closed defect (fixed)

When I tried put comment Slovakian language I got

Reported by: vlado Owned by:
Priority: major Milestone: 0.7.0
Component: programming Keywords:
Cc: berkerpeksag Parent Tickets:

Description

URL: http://goblin.labath.info/u/vlado/m/112/comment/add/
File '/srv/goblin/mediagoblin/local/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/paste/exceptions/errormiddleware.py', line 144 in call

app_iter = self.application(environ, sr_checker)

File '/srv/goblin/mediagoblin/local/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/paste/urlmap.py', line 203 in call

return app(environ, start_response)

File '/srv/goblin/mediagoblin/mediagoblin/app.py', line 259 in call

return self.call_backend(environ, start_response)

File '/srv/goblin/mediagoblin/mediagoblin/app.py', line 236 in call_backend

response = controller(request)

File '/srv/goblin/mediagoblin/mediagoblin/decorators.py', line 228 in wrapper

return controller(request, media=media, *args, kwargs)

File '/srv/goblin/mediagoblin/mediagoblin/decorators.py', line 52 in new_controller_func

return controller(request, *args, kwargs)

File '/srv/goblin/mediagoblin/mediagoblin/user_pages/views.py', line 168 in media_post_comment

print request.formcomment_content

File '/srv/goblin/mediagoblin/local/lib/python2.7/site-packages/PasteScript-1.7.5-py2.7.egg/paste/script/serve.py', line 530 in write

fileobj.write(text)

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

Change History (12)

comment:1 by tryggvib, 11 years ago

I finally got so irritated with this bug (because I also happen to run into it quite frequently, running an international site) that I fixed it.

Here ya go:
https://gitorious.org/mediagoblin/tryggvi-mediagoblin/source/d06e59525a9883f99382a3da7014182eefc9a229:

comment:2 by tryggvib, 11 years ago

Status: newreview

comment:3 by Christopher Allan Webber, 10 years ago

Milestone: 0.7.0

comment:4 by berkerpeksag, 10 years ago

Cc: berkerpeksag added

comment:5 by Jessica Tallon, 10 years ago

I'm currently unable to reproduce this error. Can someone provide some steps that I can follow which will produce this error on the latest mater?

comment:6 by Jessica Tallon, 10 years ago

Thanks to help from tryggvib what needs to be done to reproduce is:

1) Upload some media
2) Log out and log in with another user
3) Leave a comment with some non-ascii characters (e.g. "aábcdðeéfghiíjklmnoópqrstuúvwxyýzþæö")
4) Log out
5) Log back in with original user and try to mark new comment notification as read

This will cause an error.

comment:7 by Jessica Tallon, 10 years ago

Resolution: fixed
Status: reviewclosed

comment:8 by berkerpeksag, 10 years ago

Sorry, but I think the patch is incorrect. __repr__ and __str__ methods must return a str object in Python 2, not unicode. There is already a __unicode__ method for that purpose.

See http://stackoverflow.com/questions/3627793/best-output-type-and-encoding-practices-for-repr-functions for more information about this.

Note: The patch works great in Python 3.

comment:9 by tryggvib, 10 years ago

Added __unicode___ representation to Notification and MediaCommentMixin objects and modified __repr___ to return str objects. It's in the same branch as before.

Here's the commit: https://gitorious.org/mediagoblin/tryggvi-mediagoblin/commit/89bd816cff47ba6d37a20e58c3053380a0c368ea

Here's the branch: https://gitorious.org/mediagoblin/tryggvi-mediagoblin/source/89bd816cff47ba6d37a20e58c3053380a0c368ea

comment:10 by tryggvib, 10 years ago

Resolution: fixed
Status: closedaccepted

Since berkerpeksag was right in the comment I provided a fix. The ticket should be reopened to show that the fix (to berkerpeksag's comment) has not been merged.

comment:11 by tryggvib, 10 years ago

Status: acceptedreview

Moving fix to berkerpeksag's comment to review.

comment:12 by Christopher Allan Webber, 10 years ago

Resolution: fixed
Status: reviewclosed

Well, LGTM. Berker is the domain expert here also.

I think maybe this could be simplified... these functions are *almost* the same. it's not important enough to figure out how, and it's not too egregious of code duplication.

Merged and closed!

Note: See TracTickets for help on using tickets.