#430: [PATCH] The AutoCompleteField widget dosen't handle non-ascii text
-----------------------------+----------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: defect | Status: reopened
Priority: normal | Milestone: 0.9
Component: TurboGears | Version:
Severity: normal | Resolution:
Keywords: jsonify json |
-----------------------------+----------------------------------------------
Changes (by kevin):
* resolution: fixed =>
* status: closed => reopened
Comment:
Bob Ippolito correctly points out that this is the wrong fix:
{{{
Looks like it's a bug in TG somewhere.. simplejson does the right thing:
>>> import simplejson
>>> print simplejson.dumps(dict(text=u'\u00bfHabla espa\u00f1ol?'))
{"text":"\u00bfHabla espa\u00f1ol?"}
but TG does not:
>>> import urllib
>>> print urllib.urlopen('http://127.0.0.1:8080/test').read()
{"tg_flash":null, "text":"¿Habla español?"}
This is apparently Kevin's fault according to svn blame:
370 kevin class GenericJSON(JSONEncoder):
829 kevin def __init__(self):
829 kevin super(GenericJSON, self).__init__
(ensure_ascii = False)
In this revision:
http://trac.turbogears.org/turbogears/changeset/829
Supposedly this "helps" non-ascii characters through JSON, but it
doesn't have the intended result.
The right fix for #430 would've been to ensure unicode strings from
browser input, instead of ensuring potential garbage makes its way
into the JSON output. In this case, it would be a change to the way
URLs (at least the query string) are handled.
This could be fixed by making cherrypy.lib.parseQueryString look at
the resultant dict for keys that are outside of ASCII and decoding
them to UTF-8... or it could be done as a filter like the formencode
NestedVariablesFilter in startup.
}}}
Bob also points out the correct fix, which is closer to what's suggested
in the original description of this ticket. The patch I applied is rolled
back in [914].
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/430>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---