Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1117 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

[PATCH] Make turbojson's encode return a generator

Reported by: arnarbi Owned by: anonymous
Priority: normal Milestone:
Component: TurboGears Version: 0.9a5
Severity: normal Keywords:
Cc:

Description

This patch makes turbojson.jsonify.encode split lines to overcome a bug in Firefox which chokes on lines over 4096 bytes.

The patch also changes encode from returning a string to being a generator. In theory, that will allow cherrypy to start outputting the jsonified data in chunks while simplejson is still working on it. This could be handy for jsonify-ing large structures, but it will break any caller that assumes encode is returning a string.

Attachments

splitlines.patch Download (527 bytes) - added by arnarbi 13 years ago.

Change History

Changed 13 years ago by arnarbi

comment:1 Changed 13 years ago by arnarbi

  • Summary changed from [PATCH] Make turbojson split lines (and return a generator) to [PATCH] Make turbojson's encode return a generator

Oh, I've been on a wild goose chase today. Apparently Firefox doesnt choke on lines longer thatn 4096 bytes - it just can't display them. Which doesn't really matter for json output except for debugging purposes.

However - I think making this a generator instead of a string-returning function is a good idea. The patch is reduced to the following then

  • return _instance.encode(obj)

+ return _instance.iterencode(obj)

comment:2 Changed 13 years ago by elvelind

  • Status changed from new to closed
  • Resolution set to fixed

commited in 1897. thanks

Note: See TracTickets for help on using tickets.