Ticket #2251 (assigned enhancement)

Opened 1 year ago

Last modified 6 months ago

[PATCH] JSON support

Reported by: okamototk Assigned to: athomas (accepted)
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Hi,

If XmlRpcPlugin support JSON protocol, it's fine to support Ajax function. I develop the patch with Shibuya.trac project which is the group by Japanese users and developers.

Please apply our patch to support json.

regards,

Takashi Okamoto

Shibuya.trac: http://sourceforge.jp/projects/shibuya-trac/wiki/FrontPage

Attachments

jsonsupport.patch (14.2 kB) - added by okamototk on 12/02/07 01:31:46.
Patch to support JSON
sample.zip (25.2 kB) - added by okamototk on 12/02/07 01:36:14.
sample for json support

Change History

12/02/07 01:31:46 changed by okamototk

  • attachment jsonsupport.patch added.

Patch to support JSON

12/02/07 01:36:14 changed by okamototk

  • attachment sample.zip added.

sample for json support

12/02/07 04:02:42 changed by anonymous

  • component changed from TracHacks to XmlRpcPlugin.

05/29/08 17:14:36 changed by tekknokrat

  • type changed from enhancement to defect.

I tried your patch with the recent releases of Trac (0.11dev-r7092) and xmlrpc (TracXMLRPC-1.0.0-py2.5.egg) and your getticket example.

I get the following error:

2008-05-30 00:00:56,759 Trac[main] DEBUG: Dispatching <Request "POST u'/json/ticket.get'">
2008-05-30 00:00:56,779 Trac[web_ui] DEBUG: /json/ticket.get matches True
2008-05-30 00:00:56,821 Trac[svn_fs] DEBUG: Subversion bindings imported
2008-05-30 00:00:56,829 Trac[api] DEBUG: action controllers for ticket workflow: ['ConfigurableTicketWorkflow']
2008-05-30 00:00:56,861 Trac[web_ui] ERROR: Cannot write in JSON: <DateTime '20080122T19:50:46' at 16f57a0>
2008-05-30 00:00:56,862 Trac[web_ui] ERROR: Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/tracrpc/web_ui.py", line 73, in process_request
    self._send_response(req, json.write(result[0]).encode('utf-8'), content_type)
  File "build/bdist.linux-x86_64/egg/tracrpc/json.py", line 935, in write
    return JsonWriter().write(obj, escaped_forward_slash)
  File "build/bdist.linux-x86_64/egg/tracrpc/json.py", line 883, in write
    self._write(obj)
  File "build/bdist.linux-x86_64/egg/tracrpc/json.py", line 903, in _write
    self._write(item)
  File "build/bdist.linux-x86_64/egg/tracrpc/json.py", line 932, in _write
    raise WriteException, "Cannot write in JSON: %s" % repr(obj)
WriteException: Cannot write in JSON: <DateTime '20080122T19:50:46' at 16f57a0>

2008-05-30 00:00:57,047 Trac[main] DEBUG: 13 unreachable objects found.

05/29/08 17:20:16 changed by tekknokrat

  • type changed from defect to enhancement.

05/29/08 19:30:07 changed by athomas

  • status changed from new to assigned.

This patch shouldn't include its own JSON parser, just add one as a dependency to the setup.py. Is there some other reason that something like simplejson can't be used?

Otherwise looks pretty good to me.

05/30/08 05:19:53 changed by tekknokrat

I removed json.py and installed the hardy package python-json. The error of last comment remains. athomas did this patch works for your config ootb? can you post your version of trac/json/xmlrpcplugin? How would I do replace json / simplejson?


Add/Change #2251 ([PATCH] JSON support)




Change Properties
Action