A JSON-RPC server for Zope2
Serve JSON-RPC requests from Zope2.
The product patches the publisher to serve JSON/RPC requests from within Zope2. It is based on:
- original product for earlier versions of Zope2 by Balazs Ree
- jsonserver for zope3 by Jim Washington firstname.lastname@example.org and Contributors
This project overrides some base zope2 code to provide the additional functionality of listening and responding properly to requests of type “application/json”.
The product was tested with Zope 2.10 and Zope 2.13
Add this egg to your Zope/Plone buildout.
Similar to xmlrpc usage.
jsonserver looks for content-type “application/json”, and handles those requests as JSON-RPC. Other http requests are not affected and will presumably work as expected.
The text of a JSON-RPC request looks like:
o jsonid is a string or number that may identify this specific request
o remotemethod is the method to call on the server
The text of a JSON-RPC response looks like:
o jsonid is the same jsonid as sent in the request
Actual implementation using e.g., urllib is left as an exercise for the reader. Hint: Use the minjson.write(object) and minjson.read(string) methods for conversion before and after transport.
The “json” namespace (http://namespaces.zope.org/json) defines the page and pages directives. json:page is identical to browser:page in the usage, but the page or method declared is allowed to be called up in a json request, but will be invisible for normal requests.
browser:page and browser:pages declarations will be available to both normal and json requests.
json:page declarations will be callable from code and their macros will be visible from other templates.
<json:page name="myjsonrpcview" for="*" class=".jsonrpc.MyJsonRpcView" permission="zope2.ViewManagementScreens" />
The code of the product can be found at: https://bitbucket.org/tomgross/products.jsonserver
- Include zcml files in Manifest.in [tom_gross]
- Another Manifest.in fix [tom_gross]
- Added Manifest.in and fixed broken egg [tom_gross]
- Use simplejson/json instead of minjson implementation [tom_gross]
- Allow utf-8 as input encoding only [tom_gross]
- Zope 2.13 compatibility [tom_gross]
- Fixed issue occured if used with diazo [tom_gross]
- fixed content-type with charset [tom_gross, thanks Steve Spicklemire]
- changed has_key with __contains__ calls [tom_gross]
- fixed sending of unauthorized status [tom_gross]
- return error object according to the JSON-RPC specification http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html#ErrorObject [tom_gross, thanks Steve Spicklemire]
- fixes for Zope 2.10
- moved from old product from http://www.zope.org/Members/ree/jsonserver2 [tom_gross]
- Tom Gross, Author
- Balazs Ree