{ "info": { "author": "saaj", "author_email": "mail@saaj.me", "bugtrack_url": null, "classifiers": [ "Framework :: CherryPy", "Intended Audience :: Developers", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Communications", "Topic :: Software Development :: Libraries" ], "description": ".. image:: https://bitbucket-badges.atlassian.io/badge/saaj/qooxdoo-cherrypy-json-rpc.svg?ref=default\r\n :target: https://bitbucket.org/saaj/qooxdoo-cherrypy-json-rpc/addon/pipelines/home\r\n.. image:: https://codecov.io/bb/saaj/qooxdoo-cherrypy-json-rpc/branch/default/graph/badge.svg\r\n :target: https://codecov.io/bb/saaj/qooxdoo-cherrypy-json-rpc/branch/default\r\n.. image:: https://badge.fury.io/py/QooxdooCherrypyJsonRpc.png\r\n :target: https://pypi.python.org/pypi/QooxdooCherrypyJsonRpc\r\n\r\n***********************************************\r\nQooxdoo-specific CherryPy-based JSON-RPC server\r\n***********************************************\r\n\r\nOverview\r\n========\r\n*Python* RPC-server for a `Qooxdoo `_ application. Implemented on top of\r\n`CherryPy `_. Supports file upload and download. Controller code example:\r\n\r\n.. sourcecode:: python\r\n\r\n import cherrypy\r\n import qxcpjsonrpc as rpc\r\n\r\n class Service:\r\n\r\n _server = rpc.Server()\r\n '''Server instance can be shared between threads'''\r\n\r\n @cherrypy.expose\r\n def index(self, *args, **kwargs):\r\n return self._server.run()\r\n\r\nAlternatively ``rpc.ServerTool`` can used in *CherryPy* configuration as follows (or\r\n`any of other ways `_ to\r\nactivate a *CherryPy* tool because of its great flexibility):\r\n\r\n.. sourcecode:: python\r\n\r\n import cherrypy\r\n import qxcpjsonrpc as rpc\r\n\r\n config = {\r\n '/service' : {\r\n 'tools.jsonrpc.on' : True\r\n }\r\n }\r\n\r\n cherrypy.tools.jsonrpc = rpc.ServerTool()\r\n\r\n cherrypy.tree.mount(None, config = config)\r\n\r\n\r\nService code example:\r\n\r\n.. sourcecode:: python\r\n\r\n import qxcpjsonrpc as rpc\r\n\r\n class Test(rpc.Service):\r\n\r\n @rpc.public\r\n def add(self, x, y):\r\n return x + y\r\n\r\n*Qooxdoo* code example:\r\n\r\n.. sourcecode:: javascript\r\n\r\n var rpc = new qx.io.remote.Rpc();\r\n rpc.setServiceName('modulename.Test');\r\n rpc.setUrl('http://127.0.0.1:8080/service');\r\n rpc.addListener(\"completed\", function(event)\r\n {\r\n console.log(event.getData());\r\n });\r\n rpc.callAsyncListeners(this, 'add', 5, 7);\r\n\r\n\r\nSerialisation\r\n=============\r\nSerialisation is provided by ``json`` package. However it doesn't work out-of-the-box for some\r\npractically important types.\r\n\r\nNo special deserialisation but ``json.loads`` is performed. Additional parsing is intended to be\r\nin user code.\r\n\r\n\r\nDate\r\n----\r\n\r\nDates are serialised to `UTC `_\r\n`ISO 8601 `_ strings, close to what *Javascript*\r\n``JSON.stringify(new Date())`` produces. ``datetime.datetime`` objects look like\r\n``'2012-03-17T19:09:12.217000Z'``, ``datetime.date`` like ``'2012-03-17T00:00:00Z'``.\r\n\r\nAs far as I know, there's no reliable and cross-browser way to parse *ISO 8601* strings using\r\n*Javascript* ``Date`` object. The following code can help (usually I put it to\r\n``Date.fromISOString``, as a counterpart to ``Date.prototype.toISOString``), which converts\r\n*ISO 8601* to cross-browser representation ``'2011/10/09 07:06:05 +0000'`` and passes it\r\nto ``Date`` constructor.\r\n\r\n.. sourcecode:: javascript\r\n\r\n function fromISOString(value)\r\n {\r\n if(!value)\r\n {\r\n return null;\r\n }\r\n\r\n return new Date(value\r\n .split(\".\")[0]\r\n .split(\"Z\")[0]\r\n .split(\"-\").join(\"/\")\r\n .replace(\"T\", \" \")\r\n + \" +0000\"\r\n );\r\n }\r\n\r\nFor dealing with *ISO 8601* strings in service user code there's a helper, which can be used\r\nas follows.\r\nNote that ``datetime.datetime`` objects it produces are timezone-aware. Timezone is *UTC*.\r\n\r\n.. sourcecode:: python\r\n\r\n import qxcpjsonrpc as rpc\r\n\r\n rpc.fromJsonDate('2012-03-17T19:09:12.217Z')\r\n\r\nDecimal\r\n-------\r\n\r\nSerialised as strings.\r\n\r\n\r\nAccess control\r\n==============\r\nBy default all methods are protected and need to be explicitly marked with ``rpc.access`` decorator\r\nto become accessible. The decorator expects a callable that returns a ``bool``. It is possible to\r\nuse the decorator multiple times.\r\n\r\nThe package doesn't use manual service bookkeeping, rather than doing imports programmatically\r\nthrough ``importlib``. In case you operate modules that have import side-effects, which are\r\nin general a good idea to eliminate, you can subclass ``rpc.ServiceLocator`` and pass it (class)\r\nto initializer of ``rpc.Server`` or ``rpc.ServerTool``. This way arbitrary method lookup can be\r\nimplemented.\r\n\r\n.. sourcecode:: python\r\n\r\n import qxcpjsonrpc as rpc\r\n\r\n def isAdmin(method, request):\r\n '''Access is granted only to administrator'''\r\n return cherrypy.request.login == 'admin'\r\n\r\n class Restricted(rpc.Service):\r\n\r\n @rpc.access(isAdmin)\r\n def entertainme(self):\r\n return '1/0 === Infinity'\r\n\r\n\r\nProtocol\r\n========\r\nBelow are some examples of typical payloads.\r\n\r\nGET\r\n---\r\nIt's usually a case of source mode *Qooxdoo* application under development. Especially when the\r\napplication is loaded from *file://* and requires *JSONP* communication to circumvent\r\nSame Origin Policy.\r\n\r\nRequest's query parameters, like in\r\n``http://localhost/service?_ScriptTransport_id=...&nocache=...&_ScriptTransport_data=...``:\r\n\r\n.. sourcecode:: javascript\r\n\r\n // _ScriptTransport_data\r\n {\r\n \"id\" : 5,\r\n \"service\" : \"modulename.Test\",\r\n \"method\" : \"anotherMethod\",\r\n \"params\" : [\"JavaScript\", {\"is\": [\"doable with Qooxdoo\"]}],\r\n \"server_data\" : {\"token\": \"a58666196537fdf3e5bf63cd740928gf\"}\r\n }\r\n\r\n // _ScriptTransport_id\r\n 5\r\n\r\n // nocache\r\n 1297107012377\r\n\r\nResponse:\r\n\r\n.. sourcecode:: javascript\r\n\r\n qx.io.remote.transport.Script._requestFinished(\r\n 5, // id\r\n {\r\n \"id\" : 5,\r\n \"error\" : {\r\n \"origin\" : 2,\r\n \"message\" : \"[ApplicationError] Wild statement!\",\r\n \"code\" : 0\r\n },\r\n \"result\" : null\r\n }\r\n );\r\n\r\n\r\nPOST\r\n----\r\nIt's usually a case of built and deployed *Qooxdoo* application.\r\n\r\nRequest to ``http://localhost/service?nocache=1234500999666``:\r\n\r\n.. sourcecode:: javascript\r\n\r\n {\r\n \"id\" : 12,\r\n \"service\" : \"modulename.Test\",\r\n \"method\" : \"anotherMethod\",\r\n \"params\" : [\"Python\", true, {\"ly\": [\"rocks\"]}],\r\n \"server_data\" : {\"token\": \"a58666196537fdf3e5bf63cd740928gf\"}\r\n }\r\n\r\nResponse:\r\n\r\n.. sourcecode:: javascript\r\n\r\n {\r\n \"id\" : 12,\r\n \"error\" : null,\r\n \"result\" : {\"arbitrary\": {\"here\": [\"a\", 5, \" well\"]}}\r\n }\r\n\r\n\r\nExamples\r\n========\r\nFor examples look in\r\n`test suite `_.\r\nMore examples could be found in `this `_\r\nproject.\r\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/saaj/qooxdoo-cherrypy-json-rpc", "keywords": "qooxdoo cherrypy javascript python rpc", "license": "LGPL-2.1+", "maintainer": "", "maintainer_email": "", "name": "QooxdooCherrypyJsonRpc", "package_url": "https://pypi.org/project/QooxdooCherrypyJsonRpc/", "platform": "Any", "project_url": "https://pypi.org/project/QooxdooCherrypyJsonRpc/", "project_urls": { "Homepage": "https://bitbucket.org/saaj/qooxdoo-cherrypy-json-rpc" }, "release_url": "https://pypi.org/project/QooxdooCherrypyJsonRpc/0.6.0/", "requires_dist": null, "requires_python": "", "summary": "Qooxdoo-specific CherryPy-based JSON-RPC server", "version": "0.6.0" }, "last_serial": 2903362, "releases": { "0.2.2": [ { "comment_text": "", "digests": { "md5": "d71a406f06cacbf427b557d809ef12f2", "sha256": "da1065c1ac07ee0061e505d94355e760d966dc41d90cd6310d6adf0f1293d690" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.2.2.zip", "has_sig": false, "md5_digest": "d71a406f06cacbf427b557d809ef12f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18978, "upload_time": "2013-03-17T18:38:45", "url": "https://files.pythonhosted.org/packages/b9/31/037e946d60b4a4912ba488b6f3816e92a5ad5902523385442d127aab1a75/QooxdooCherrypyJsonRpc-0.2.2.zip" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "ae7e41ef13b9f5b11520b74edae5d0c8", "sha256": "a71d4b82bfb87ff7a113ca2df838c9478378a07e6051a47237b9f9fe969934c1" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.3.0.zip", "has_sig": false, "md5_digest": "ae7e41ef13b9f5b11520b74edae5d0c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19254, "upload_time": "2013-03-26T08:49:05", "url": "https://files.pythonhosted.org/packages/0f/d2/c13f7c27346eca0da2df67d7babfa472bbf16c251f485c834ea0b693a9dc/QooxdooCherrypyJsonRpc-0.3.0.zip" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "baf8f898986ea67fc8fc52cf9162e612", "sha256": "ecfdd38ec4aedc269ebfde663b0dcdaea63fe77cc986a82254d2db1f3b06e60d" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.3.1.tar.gz", "has_sig": false, "md5_digest": "baf8f898986ea67fc8fc52cf9162e612", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13756, "upload_time": "2014-04-09T11:39:25", "url": "https://files.pythonhosted.org/packages/7b/c0/9766cc4e7f2105f5394422312d2c990c87e3916d934e87381f59a8363a46/QooxdooCherrypyJsonRpc-0.3.1.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "6f1748416bdf2ef2c973d194f7367c59", "sha256": "cfde9fdf115a100e2eac9be5795ac832e3211aedb62b63d9b933d3d0cbf759ef" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.4.0.tar.gz", "has_sig": false, "md5_digest": "6f1748416bdf2ef2c973d194f7367c59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16782, "upload_time": "2014-04-14T17:05:58", "url": "https://files.pythonhosted.org/packages/a9/44/671071971711626e7c01217698118713e9aede874d08bb7cf6c03d3831c7/QooxdooCherrypyJsonRpc-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "f99a1a91876f9f4a2ecc7090e9915ed6", "sha256": "37c825f7f0f8a97675ff33cafeee0411595b51b2d61f25a7836a94a00cf008a3" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.4.1.tar.gz", "has_sig": false, "md5_digest": "f99a1a91876f9f4a2ecc7090e9915ed6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16782, "upload_time": "2014-04-14T17:16:19", "url": "https://files.pythonhosted.org/packages/6c/a1/1912447855b9d9d676d17e59d91793a41bcb351a719b1f7e9627198d9e9f/QooxdooCherrypyJsonRpc-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "431ab4ec24e1e300ddaee1e759e32df0", "sha256": "69895b3835b67a03f348b01b430915c448bf7503975038852b714e5322a849ab" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.4.2.tar.gz", "has_sig": false, "md5_digest": "431ab4ec24e1e300ddaee1e759e32df0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16876, "upload_time": "2014-04-14T17:43:58", "url": "https://files.pythonhosted.org/packages/b8/61/e3c2080ac182b931e04acee547effcc8a4c2438c2420479f374c8404ab81/QooxdooCherrypyJsonRpc-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "0a53bcbd02d41de6f2adc99b4c7a54d4", "sha256": "56b1ef46d90867e5da90122168c065de602ed505c2aeea5a9336ff06b8eba282" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.4.3.tar.gz", "has_sig": false, "md5_digest": "0a53bcbd02d41de6f2adc99b4c7a54d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17284, "upload_time": "2014-04-20T14:24:06", "url": "https://files.pythonhosted.org/packages/73/d4/2a2d1a838fa43afc4efe315e2201647052de94507cbc873c23bf71e50082/QooxdooCherrypyJsonRpc-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "0ed2c9ca747b157fa85b6d63dc46e397", "sha256": "7a19f99758bc8c13cc34d7de3a9780eed0760ff43319e584f6ec2af0dd83ff90" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.4.4.tar.gz", "has_sig": false, "md5_digest": "0ed2c9ca747b157fa85b6d63dc46e397", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 41647, "upload_time": "2014-07-09T18:03:50", "url": "https://files.pythonhosted.org/packages/32/19/b87b1f5a9278cc4d39843dd4854b5c0685909b527ea9c03db1c14d6aa036/QooxdooCherrypyJsonRpc-0.4.4.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "5d2931e3a33b2b269d4adc227c768122", "sha256": "6defdbb2857397db90300120885708ad08359374a67e490b568b01540c9d4168" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.5.0.tar.gz", "has_sig": false, "md5_digest": "5d2931e3a33b2b269d4adc227c768122", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 41844, "upload_time": "2014-10-02T10:02:16", "url": "https://files.pythonhosted.org/packages/b7/85/08b5f5ab6708ec49ae3171a029a86226b4db2ef4cbc4d98ab124fc877950/QooxdooCherrypyJsonRpc-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "0f6587f16d498abeff56b7428b202de2", "sha256": "c6f2cc41e3fdcf9bbe44dba2127ea39bdd20e9d80f994dd520f74397319390c1" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.5.1.tar.gz", "has_sig": false, "md5_digest": "0f6587f16d498abeff56b7428b202de2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42103, "upload_time": "2015-03-13T13:33:09", "url": "https://files.pythonhosted.org/packages/c5/65/46a803241ea6125511f39521b943b4ae4792f63d289ed3bd6e365a39991a/QooxdooCherrypyJsonRpc-0.5.1.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "9bdb4ed6601a0413b830cf4e72c0182e", "sha256": "be63b0754aed8b4c8a5e9d2ea82b86283037331b094721892b5c1c7e42bbbf22" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.6.0.tar.gz", "has_sig": false, "md5_digest": "9bdb4ed6601a0413b830cf4e72c0182e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38922, "upload_time": "2017-05-27T14:15:39", "url": "https://files.pythonhosted.org/packages/12/cf/881b9821c5f3f37a263894d14ba321cda42064c40e2a0f8d25af896467fe/QooxdooCherrypyJsonRpc-0.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9bdb4ed6601a0413b830cf4e72c0182e", "sha256": "be63b0754aed8b4c8a5e9d2ea82b86283037331b094721892b5c1c7e42bbbf22" }, "downloads": -1, "filename": "QooxdooCherrypyJsonRpc-0.6.0.tar.gz", "has_sig": false, "md5_digest": "9bdb4ed6601a0413b830cf4e72c0182e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38922, "upload_time": "2017-05-27T14:15:39", "url": "https://files.pythonhosted.org/packages/12/cf/881b9821c5f3f37a263894d14ba321cda42064c40e2a0f8d25af896467fe/QooxdooCherrypyJsonRpc-0.6.0.tar.gz" } ] }