[Twisted-web] small json improvements

Eric Faurot eric.faurot at gmail.com
Mon Sep 5 14:14:58 MDT 2005

On 9/5/05, Jp Calderone <exarkun at divmod.com> wrote:
> On Mon, 5 Sep 2005 09:56:05 +0200, Eric Faurot <eric.faurot at gmail.com> wrote:
> >On 9/4/05, Jp Calderone <exarkun at divmod.com> wrote:
> >
> > [snip]
> >
> >All I wanted was to be able to serialize 'regular' strings
> >conveniently. Of course
> >strings containing non-printable chars should be handled differently.

> It sounds like you're in favor of the treat-as-ASCII rule then.  I've certainly written code that would have benefited from this behavior too, I just want to make sure there's no lurking downside before making the change.

Just because it is more convenient and it is what is expected many cases
where strings are used (email address, hostnames, ip address...).
The string could be checked by the serializer to ensure that it does not
contain non-ASCII chars, in wich case a contextual string serializer can be
used instead (on a per page basis for example)

> >Could you elaborate on this? I'm not sure to understand the issue here.
> >What are javascript/browser requirements regarding unicode?
> The problem is server-side (at least for the moment).  json.serialize() will do something if you give it a unicode string, but it will usually not be the correct thing.  This is fixable, someone just needs to get around to it.

So what is the correct thing to do?

BTW, this patch should allow deferred response from callRemote, but I does
not seem to work. I don't understand why.


More information about the Twisted-web mailing list