{ "info": { "author": "Atsushi Odagiri", "author_email": "aodagx@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application" ], "description": ".. -*- restructuredtext -*-\r\n\r\n.. image:: https://drone.io/bitbucket.org/aodag/jsonrpc2/status.png\r\n :target: https://drone.io/bitbucket.org/aodag/jsonrpc2/latest\r\n\r\njsonrpc2 is WSGI Framework for JSON RPC 2.0.\r\n\r\nJSON RPC 2.0 Spec can be seen on http://www.jsonrpc.org/specification .\r\n\r\n.. contents::\r\n\r\nQuickStart\r\n==========================================\r\n\r\ninstall via pip::\r\n\r\n $ pip install jsonrpc2\r\n\r\nwrite your procedures in hello.py::\r\n\r\n def greeting(name):\r\n return dict(message=\"Hello, %s!\" % name)\r\n\r\nrun jsonrpc2 server::\r\n\r\n $ runjsonrpc2 hello\r\n\r\n\r\nIntegration with Paste Script\r\n===============================================\r\n\r\ncreate project with paste script template::\r\n\r\n $ paster create -t paster_jsonrpc2 myrpc\r\n $ cd myrpc\r\n\r\nrun server\r\n\r\n $ paster serve run.ini\r\n\r\naccess http://localhost:8080/\r\n\r\n\r\nInternal\r\n===============================\r\n\r\n::\r\n\r\n >>> import json\r\n >>> from jsonrpc2 import JsonRpcApplication\r\n\r\nsample procedure::\r\n\r\n >>> def greeting(name=\"world\"):\r\n ... return \"Hello, %s!\" % name\r\n\r\ncreate rpc application::\r\n\r\n >>> app = JsonRpcApplication(rpcs=dict(greeting=greeting))\r\n\r\nset up for test::\r\n\r\n >>> from webtest import TestApp\r\n >>> testapp = TestApp(app)\r\n\r\ncall procedure::\r\n\r\n >>> call_values = {'jsonrpc':'2.0', 'method':'greeting', 'id':'greeting'}\r\n >>> res = testapp.post('/', params=json.dumps(call_values), content_type=\"application/json\")\r\n\r\ngot results::\r\n\r\n >>> res.json\r\n {u'jsonrpc': u'2.0', u'id': u'greeting', u'result': u'Hello, world!'}\r\n\r\n\r\nlazy loading::\r\n\r\n >>> app.rpc.methods['sample.add'] = 'tests.sample:add'\r\n >>> call_values = {'jsonrpc':'2.0', 'method':'sample.add', 'id':'sample.add', 'params':[1, 2]}\r\n >>> res = testapp.post('/', params=json.dumps(call_values), content_type=\"application/json\")\r\n >>> res.json\r\n {u'jsonrpc': u'2.0', u'id': u'sample.add', u'result': 3}\r\n\r\n\r\nextra vars\r\n==================\r\n\r\n::\r\n\r\n >>> from jsonrpc2 import JsonRpc\r\n >>> rpc = JsonRpc()\r\n >>> rpc['add'] = lambda a, b: a + b\r\n >>> rpc({'jsonrpc': '2.0', 'method': 'add', 'id': 'rpc-1', 'params': {'a': 2}}, b=3)\r\n {'jsonrpc': '2.0', 'id': 'rpc-1', 'result': 5}\r\n\r\nhandle errors\r\n=================\r\n\r\n::\r\n\r\n >>> from jsonrpc2 import JsonRpc\r\n >>> class MyException(Exception):\r\n ... pass\r\n >>> def my_rpc():\r\n ... raise MyException()\r\n >>> rpc = JsonRpc({'call': my_rpc}, {MyException: -32001})\r\n >>> rpc({'jsonrpc': '2.0', 'method': 'call', 'id': 'rpc-1', 'params': []})\r\n {'jsonrpc': '2.0', 'id': 'rpc-1', 'error': {'message': '', 'code': -32001, 'data': '[]'}}\r\n\r\n\r\nJSON-RPC2 Example\r\n=====================================================\r\n\r\nuse raw rpc processor::\r\n\r\n >>> from jsonrpc2 import JsonRpc\r\n >>> rpc = JsonRpc()\r\n\r\nsample procedures::\r\n\r\n >>> def subtract(minuend, subtrahend):\r\n ... return minuend - subtrahend\r\n >>> def update(*args):\r\n ... pass\r\n >>> def foobar():\r\n ... pass\r\n\r\nregister procedures with dict interface::\r\n\r\n >>> rpc['subtract'] = subtract\r\n >>> rpc['update'] = update\r\n >>> rpc['foobar'] = foobar\r\n\r\nProcedure Call with positional parameters::\r\n\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42, 23], \"id\": 1})\r\n {'jsonrpc': '2.0', 'id': 1, 'result': 19}\r\n\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [23, 42], \"id\": 2})\r\n {'jsonrpc': '2.0', 'id': 2, 'result': -19}\r\n\r\nProcedure Call with named parameters::\r\n\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": {\"subtrahend\": 23, \"minuend\": 42}, \"id\": 3})\r\n {'jsonrpc': '2.0', 'id': 3, 'result': 19}\r\n\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": {\"minuend\": 42, \"subtrahend\": 23}, \"id\": 4})\r\n {'jsonrpc': '2.0', 'id': 4, 'result': 19}\r\n\r\nNotification::\r\n\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"update\", \"params\": [1,2,3,4,5]})\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"foobar\"})\r\n\r\nProcedure Call of non-existent procedure::\r\n\r\n >>> del rpc['foobar']\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": \"foobar\", \"id\": \"1\"})\r\n {'jsonrpc': '2.0', 'id': '1', 'error': {'message': 'Method Not Found', 'code': -32601}}\r\n\r\nProcedure Call with invalid JSON-RPC::\r\n\r\n >>> rpc([1,2,3])\r\n {'jsonrpc': '2.0', 'id': None, 'error': {'message': 'Invalid Request', 'code': -32600}}\r\n\r\n >>> rpc({\"jsonrpc\": \"2.0\", \"method\": 1, \"params\": \"bar\"})\r\n {'jsonrpc': '2.0', 'id': None, 'error': {'message': 'Invalid Request', 'code': -32600}}\r\n\r\n\r\nBatched Call::\r\n\r\n >>> rpc['sum'] = lambda *args: reduce(lambda a, b: a + b, args)\r\n >>> def get_data():\r\n ... return [\"hello\", 5]\r\n >>> rpc['get_data'] = get_data\r\n >>> result = rpc ([ {\"jsonrpc\": \"2.0\", \"method\": \"sum\", \"params\": [1,2,4], \"id\": \"1\"},\r\n ... {\"jsonrpc\": \"2.0\", \"method\": \"notify_hello\", \"params\": [7]},\r\n ... {\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": [42,23], \"id\": \"2\"},\r\n ... {\"foo\": \"boo\"},\r\n ... {\"jsonrpc\": \"2.0\", \"method\": \"foo.get\", \"params\": {\"name\": \"myself\"}, \"id\": \"5\"},\r\n ... {\"jsonrpc\": \"2.0\", \"method\": \"get_data\", \"id\": \"9\"} ])\r\n >>> from pprint import pprint\r\n >>> pprint(result)\r\n [{'id': '1', 'jsonrpc': '2.0', 'result': 7},\r\n {'error': {'code': -32601, 'message': 'Method Not Found'},\r\n 'id': None,\r\n 'jsonrpc': '2.0'},\r\n {'id': '2', 'jsonrpc': '2.0', 'result': 19},\r\n {'error': {'code': -32600, 'message': 'Invalid Request'},\r\n 'id': None,\r\n 'jsonrpc': '2.0'},\r\n {'error': {'code': -32601, 'message': 'Method Not Found'},\r\n 'id': '5',\r\n 'jsonrpc': '2.0'},\r\n {'id': '9', 'jsonrpc': '2.0', 'result': ['hello', 5]}]\r\n\r\n\r\n\r\nChangeLog\r\n===================================================\r\n\r\n0.4.1\r\n------------------------------\r\n\r\n- 0.4 is brown bag release.\r\n\r\n0.4\r\n-----------------------------------------------\r\nfeature\r\n\r\n- added supporting py3\r\n- added registering application errors\r\n\r\nfixed bugs\r\n\r\n- Dont raise internal error for server exceptions `#13 `_\r\n- incorrect Content-type `#15 `_\r\n- internal logging configuration broken `#16 `_\r\n\r\n0.3\r\n-----------------------------------------------\r\n\r\n- fix bugs\r\n- Paste Scripte templates\r\n- runjsonrpc2 command\r\n\r\n0.3.1\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n- fix bugs (content-type with charset)\r\n\r\n0.3.2\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n- enable to pass the extra vars to procedures\r\n\r\n0.2\r\n-----------------------------------------------\r\n\r\n- remove dependency to WebOb\r\n- split procedure call class from web application class\r\n\r\n0.2.1\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n- lazy loading from method name.\r\n\r\n0.2.2\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n- add dict interface.\r\n\r\n0.2.3\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n- fix: read body with CONTENT_LENGTH.", "description_content_type": null, "docs_url": "https://pythonhosted.org/jsonrpc2/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://hg.aodag.jp/jsonrpc2/", "keywords": "wsgi request web http json rpc", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "jsonrpc2", "package_url": "https://pypi.org/project/jsonrpc2/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/jsonrpc2/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://hg.aodag.jp/jsonrpc2/" }, "release_url": "https://pypi.org/project/jsonrpc2/0.4.1/", "requires_dist": null, "requires_python": null, "summary": "WSGI Framework for JSON RPC 2.0", "version": "0.4.1" }, "last_serial": 1052564, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "174c5b2f54635e7b747e1b31c9863d30", "sha256": "ca45d9efb7cb7831b1d0cae6dacb77860fb95f3dd6afe23084db2e289cb8201b" }, "downloads": -1, "filename": "jsonrpc2-0.1-py2.5.egg", "has_sig": false, "md5_digest": "174c5b2f54635e7b747e1b31c9863d30", "packagetype": "bdist_egg", "python_version": "2.5", "requires_python": null, "size": 1225, "upload_time": "2010-02-05T12:30:52", "url": "https://files.pythonhosted.org/packages/fc/31/4e007596b924614e27cb1483c2d49a185dc956e67a527b3ffecff049d0d5/jsonrpc2-0.1-py2.5.egg" }, { "comment_text": "", "digests": { "md5": "6631c02989e05398b751a86ee7c312a3", "sha256": "e4c5bcb4aee5dc0b50899b9a2e3d06e228862e2a08eeaef57e1390046d8008a2" }, "downloads": -1, "filename": "jsonrpc2-0.1.win32.exe", "has_sig": false, "md5_digest": "6631c02989e05398b751a86ee7c312a3", "packagetype": "bdist_wininst", "python_version": "2.5", "requires_python": null, "size": 63514, "upload_time": "2010-02-05T12:30:36", "url": "https://files.pythonhosted.org/packages/b9/73/acb5341748d1bdc3e4b4d178b74f408ed02e28ba70ee03ae8209c2ce6536/jsonrpc2-0.1.win32.exe" }, { "comment_text": "", "digests": { "md5": "2ecea1f214c80a620bdada0bf5629945", "sha256": "b0a5bb57b416a0a44997dbeb29efb2e65a8b6d1c88c280606b0b66db3c21aaa2" }, "downloads": -1, "filename": "jsonrpc2-0.1.zip", "has_sig": false, "md5_digest": "2ecea1f214c80a620bdada0bf5629945", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2537, "upload_time": "2010-02-05T12:30:01", "url": "https://files.pythonhosted.org/packages/61/00/2a1e13cd765b3ff4c0accdd6e738c58895345a0a8550de90c6e308914f2c/jsonrpc2-0.1.zip" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ef445066077240e66c834d7ee0b21a50", "sha256": "20d64565c8d48357712b67e1dd53636769ce7d47f7e9b5879d40b1b33bfb93a1" }, "downloads": -1, "filename": "jsonrpc2-0.2.zip", "has_sig": false, "md5_digest": "ef445066077240e66c834d7ee0b21a50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5845, "upload_time": "2010-10-16T09:11:41", "url": "https://files.pythonhosted.org/packages/ed/19/0ef46af2ca9adfd48f77b7ef03402ff5ea6f4933af7e3f32d3ebfba6e0bb/jsonrpc2-0.2.zip" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "1659a5905c294f382939fcceb61c4b08", "sha256": "399802086ecc0e9cfdd1906f73b8d42b2dabf5c7dcef99f54ed3800e89f15e23" }, "downloads": -1, "filename": "jsonrpc2-0.2.1.tar.gz", "has_sig": false, "md5_digest": "1659a5905c294f382939fcceb61c4b08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4695, "upload_time": "2010-10-18T05:26:24", "url": "https://files.pythonhosted.org/packages/ef/39/4197487f91e4fd6ff34f5d371da9f2c3d9f537398328322a0197a1a3c205/jsonrpc2-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "5ce4e820d78e979aafda8badec4ac635", "sha256": "1b8626290dbcd05e602d972e2d94325e48c26a650e0c9b2fa56ace0b71888001" }, "downloads": -1, "filename": "jsonrpc2-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5ce4e820d78e979aafda8badec4ac635", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5792, "upload_time": "2010-10-19T07:25:40", "url": "https://files.pythonhosted.org/packages/95/03/329e028d68b951c1b987721ec9e59b9535b6167b55e8720841ebf0e1b874/jsonrpc2-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "e1f290a32194a4083b64f9566781b7c1", "sha256": "7729976627c3e87900a22561d7ad9a9c139dc769a570c577811b3a087449b029" }, "downloads": -1, "filename": "jsonrpc2-0.2.3.tar.gz", "has_sig": false, "md5_digest": "e1f290a32194a4083b64f9566781b7c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5896, "upload_time": "2010-11-07T08:38:34", "url": "https://files.pythonhosted.org/packages/b2/23/1e17d74f2e2b942350c3c200ccb89dadbb2893345a25d2d0ed97fe48f47c/jsonrpc2-0.2.3.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "3ecf9aeef014867da518d7fb45220733", "sha256": "4d845d91678c546c5acb78a17fb2f5970875c95a49a93f3f0fb8d09c78392cc4" }, "downloads": -1, "filename": "jsonrpc2-0.3.zip", "has_sig": false, "md5_digest": "3ecf9aeef014867da518d7fb45220733", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21775, "upload_time": "2010-11-20T08:45:17", "url": "https://files.pythonhosted.org/packages/c6/34/150bb697ceff065bc619216949756ef34f54be374b4c234f442cb276b71f/jsonrpc2-0.3.zip" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "e98266099f092f512c406c06268e0cf8", "sha256": "daa5fe4d8922c9b68ff1215ba1a14d51c6563dd973dacf68bfaa15b1dcb32c17" }, "downloads": -1, "filename": "jsonrpc2-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e98266099f092f512c406c06268e0cf8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13400, "upload_time": "2011-04-22T04:25:42", "url": "https://files.pythonhosted.org/packages/26/01/237c8e8820d679ae063570f6fda8bfc16e7af42f918844242dca7f65fda1/jsonrpc2-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "b395badecd18f91c7e4bc41f05bfb82f", "sha256": "c8908ed5c37ea425c86b51aa09b402d1efd40b13de518ad915e9fab6cecfe355" }, "downloads": -1, "filename": "jsonrpc2-0.3.2.tar.gz", "has_sig": false, "md5_digest": "b395badecd18f91c7e4bc41f05bfb82f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13560, "upload_time": "2011-06-06T08:19:44", "url": "https://files.pythonhosted.org/packages/14/10/4e19268df81d38753ebba8dfa621018a2f9dd83f2c73c799753aff89587b/jsonrpc2-0.3.2.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "3ab3841c33711002446ef8828736a4a8", "sha256": "843068e8d64a8395383159822faa49a7d7e8cbb196133746ef2ce06b1ad51adf" }, "downloads": -1, "filename": "jsonrpc2-0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3ab3841c33711002446ef8828736a4a8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 20098, "upload_time": "2014-04-06T12:04:00", "url": "https://files.pythonhosted.org/packages/39/74/09e920fb8bc732d3e6283af086092707296b0f9faf1d8516a3d40413c771/jsonrpc2-0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f3d7eb7bcb6dc7fc5c14821198b44af7", "sha256": "45b774e06f4e91885f9340cc7c0a33542bf86eec74d796689fcafbed5f63716f" }, "downloads": -1, "filename": "jsonrpc2-0.4.tar.gz", "has_sig": false, "md5_digest": "f3d7eb7bcb6dc7fc5c14821198b44af7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15153, "upload_time": "2014-04-06T12:03:56", "url": "https://files.pythonhosted.org/packages/36/23/d4d0c2af6c8abe9560195b2833dfd5d64aca7483ce84826e8cd6d6db3c06/jsonrpc2-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "6f3d2f3f0eba852ab81071334e193ca3", "sha256": "de66e608c14f6a2dd532c2233b85784d201e8754dc59fc998d81b1ce8973660b" }, "downloads": -1, "filename": "jsonrpc2-0.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6f3d2f3f0eba852ab81071334e193ca3", "packagetype": "bdist_wheel", "python_version": "3.3", "requires_python": null, "size": 20182, "upload_time": "2014-04-06T12:11:56", "url": "https://files.pythonhosted.org/packages/77/69/e41800d6ce7bca4f2409842e93325e12604493d6d9b226c0dcf733a195aa/jsonrpc2-0.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1fce3d89554325e0a3a80f69b7e806c8", "sha256": "ca1be95bcda87578c2851a478e7092a150a41bcc99942addd1ffe0f033e5228e" }, "downloads": -1, "filename": "jsonrpc2-0.4.1.tar.gz", "has_sig": false, "md5_digest": "1fce3d89554325e0a3a80f69b7e806c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15215, "upload_time": "2014-04-06T12:11:53", "url": "https://files.pythonhosted.org/packages/cb/95/62a7675260b3156fc79bf5692d8173d9cee134b421f347eae3e7c54ac60f/jsonrpc2-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6f3d2f3f0eba852ab81071334e193ca3", "sha256": "de66e608c14f6a2dd532c2233b85784d201e8754dc59fc998d81b1ce8973660b" }, "downloads": -1, "filename": "jsonrpc2-0.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6f3d2f3f0eba852ab81071334e193ca3", "packagetype": "bdist_wheel", "python_version": "3.3", "requires_python": null, "size": 20182, "upload_time": "2014-04-06T12:11:56", "url": "https://files.pythonhosted.org/packages/77/69/e41800d6ce7bca4f2409842e93325e12604493d6d9b226c0dcf733a195aa/jsonrpc2-0.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1fce3d89554325e0a3a80f69b7e806c8", "sha256": "ca1be95bcda87578c2851a478e7092a150a41bcc99942addd1ffe0f033e5228e" }, "downloads": -1, "filename": "jsonrpc2-0.4.1.tar.gz", "has_sig": false, "md5_digest": "1fce3d89554325e0a3a80f69b7e806c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15215, "upload_time": "2014-04-06T12:11:53", "url": "https://files.pythonhosted.org/packages/cb/95/62a7675260b3156fc79bf5692d8173d9cee134b421f347eae3e7c54ac60f/jsonrpc2-0.4.1.tar.gz" } ] }