{ "info": { "author": "Harrison Harnisch", "author_email": "hharnisc@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Other/Nonlisted Topic" ], "description": "# python-ddp\n\nAn event driven ddp client\n\n**Installation**\n\n```bash\n$ pip install python-ddp\n```\n\n**Table of Contents**\n\n- [History](#history)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n- [Collaborators](#collaborators)\n\n## History\n\n**Latest Version** 0.1.5\n- Handle DDP versions _1_, _pre2_ and _pre1_ (thanks [@ppettit](https://github.com/ppettit))\n- Added [EJSON](http://docs.meteor.com/#/full/ejson) support (thanks [@tdamsma](https://github.com/tdamsma))\n\n**Version** 0.1.4\n\n- BUGFIX - fix reconnect order (thanks [@ppettit](https://github.com/ppettit))\n- BUGFIX - fix breaking change (thanks [@ppettit](https://github.com/ppettit))\n\n**Version** 0.1.3\n\n- BUGFIX - closed python meteor [issue #5](https://github.com/hharnisc/python-meteor/issues/5)\n\n**Version** 0.1.2\n\n- BUGFIX - auto reconnect can now handle WebSocketExceptions (thanks [@ppettit](https://github.com/ppettit))\n\n**Version** 0.1.1\n\n- Implemented auto reconnect (auto reconnect on by default) and reconnected event emitter\n\n**Version** 0.1.0\n\n- Initial implementation, add ability to call, subscribe and unsubscribe\n\n## Quick Start\n\n### General Commands\n\n**Establish A Connection And Close It**\n\n```python\nfrom DDPClient import DDPClient\n\nclient = DDPClient('ws://127.0.0.1:3000/websocket')\nclient.connect()\nclient.close()\n```\n\n**Establish A Connection Without Auto Reconnect**\n\n```python\nfrom DDPClient import DDPClient\nclient = DDPClient('ws://127.0.0.1:3000/websocket', auto_reconnect=False)\nclient.connect()\n```\n\n**Establish A Connection And With Reconnect Different Frequency**\n\n```python\nfrom DDPClient import DDPClient\n# try to reconnect every second\nclient = DDPClient('ws://127.0.0.1:3000/websocket', auto_reconnect=True, auto_reconnect_timeout=1)\nclient.connect()\n```\n\n**Call A Remote Function**\n\n```python\nfrom DDPClient import DDPClient\n\ndef callback_function(data):\n print data\n\nclient = DDPClient('ws://127.0.0.1:3000/websocket')\nclient.connect()\nclient.call('someFunction', [1,2,3], callback_function)\n```\n\n**Subscribe and Unsubscribe**\n\n```python\nfrom DDPClient import DDPClient\n\ndef subscription_callback(data):\n print data\n\nclient = DDPClient('ws://127.0.0.1:3000/websocket')\nclient.connect()\nsub_id = client.subscribe('posts', subscription_callback)\nclient.unsubscribe(sub_id)\n```\n\n## Usage\n\n### Class Init\n\n####DDPClient(url, auto_reconnect=True, auto_reconnect_timeout=0.5, debug=False)\n\n**Arguments**\n\n_url_ - to connect to ddp server\n\n**Keyword Arguments**\n\n_auto_reconnect_ - automatic reconnect (default: True) \n_auto_reconnect_timeout_ - reconnect every X seconds (default: 0.5) \n_debug_ - print out lots of debug info (default: False) \n \n### Functions\n\n####call(self, method, params, callback=None)\n\nCall a method on the server\n\n**Arguments**\n\n_method_ - the remote server method \n_params_ - an array of commands to send to the method \n\n**Keyword Arguments**\n\n_callback_ - a callback function containing the return data\n\n####subscribe(self, name, params, callback=None)\n\nSubcribe to add/change/remove events for a collection\n\n**Arguments**\n\n_name_ - the name of the publication to subscribe \n_params_ - params to subscribe (parsed as json) \n\n**Keyword Arguments**\n\n_callback_ - a callback function that gets executed when the subscription has completed \n\n\n####unsubscribe(self, sub_id)\n\nUnsubscribe from a collection\n\n**Arguments**\n\n_sub_id_ - the id of the subsciption (returned by subcribe) \n\n### Events and Callback Arguments\n\nWhen creating an instance of `DDPClient` it is capable of emitting a few events with arguments. The documentation below assumes that you've instanciated a client with the following code:\n\n```python\nfrom DDPClient import DDPClient\nclient = DDPClient('ws://127.0.0.1:3000/websocket')\n```\n\n#### connected\n\nRegister the event to a callback function\n\n```python\ndef connected(self):\n print '* CONNECTED'\n\nclient.on('connected', connected)\n```\n\nThe connected event callback takes no arguments\n\n#### socket_closed\n\nRegister the event to a callback function\n\n```python\ndef closed(self, code, reason):\n print '* CONNECTION CLOSED {} {}'.format(code, reason)\n\nclient.on('socket_closed', closed)\n```\n\n`socket_closed` callback takes the following arguments\n\n_code_ - the error code \n_reason_ - the error message \n\n### reconnected\n\n```python\ndef reconnected(self):\n print '* RECONNECTED'\n\nclient.on('reconnected', reconnected)\n```\n\n`reconnected` call back takes no arguments\n\n#### failed\n\nRegister the event to a callback function\n\n```python\ndef failed(collection, data):\n print '* FAILED - data: {}'.format(str(data))\n\nclient.on('failed', failed)\n```\n\n`failed` callback takes the following arguments\n\n_data_ - the error data \n\n#### version_mismatch\n\nRegister the event to a callback function\n\nThis event is fired if the server and client can not agree on a DDP version to use and is a fatal error\n\n```python\ndef version_mismatch(versions):\n print '* VERSION MISMATCH - versions: {}'.format(str(versions))\n\nclient.on('version_mismatch', version_mismatch)\n```\n\n`version_mismatch` callback takes the following arguments\n\n_versions_ - the DDP versions attempted\n\n#### added\n\nRegister the event to a callback function\n\n```python\ndef added(collection, id, fields):\n print '* ADDED {} {}'.format(collection, id)\n for key, value in fields.items():\n print ' - FIELD {} {}'.format(key, value)\n\nclient.on('added', added)\n```\n\n`added` callback takes the following arguments\n\n_collection_ - the collection that has been modified \n_id_ - the collection item id\n_fields_ - the fields for item\n\n#### changed\n\nRegister the event to a callback function\n\n```python\ndef changed(self, collection, id, fields, cleared):\n print '* CHANGED {} {}'.format(collection, id)\n for key, value in fields.items():\n print ' - FIELD {} {}'.format(key, value)\n for key, value in cleared.items():\n print ' - CLEARED {} {}'.format(key, value)\n\nclient.on('changed', changed)\n```\n\n`changed` callback takes the following arguments\n\n_collection_ - the collection that has been modified \n_id_ - the collection item id\n_fields_ - the fields for item \n_cleared_ - the fields for the item that have been removed\n\n#### removed\n\nRegister the event to a callback function\n\n```python\ndef removed(collection, id):\n print '* REMOVED {} {}'.format(collection, id)\n\nclient.on('removed', removed)\n```\n\n`removed` callback takes the following arguments\n\n_collection_ - the collection that has been modified \n_id_ - the collection item id\n\n####All of the callbacks\n\nFor reference\n\n```python\nclient.on('connected', connected)\nclient.on('socket_closed', closed)\nclient.on('reconnected', reconnected)\nclient.on('failed', failed)\nclient.on('version_mismatch', version_mismatch)\nclient.on('added', added)\nclient.on('changed', changed)\nclient.on('removed', removed)\n```\n\n##Collaborators\n\n- [@ppettit](https://github.com/ppettit)\n- [@tdamsma](https://github.com/tdamsma)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hharnisc/python-ddp", "keywords": "meteor,ddp,events,emitter,node.js,node,eventemitter,event_emitter,ejson", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "python-ddp", "package_url": "https://pypi.org/project/python-ddp/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-ddp/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/hharnisc/python-ddp" }, "release_url": "https://pypi.org/project/python-ddp/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "An event driven ddp client", "version": "0.1.5" }, "last_serial": 1490299, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "8a4a847ecba5cb86c8ae8c288d12de36", "sha256": "3d5c5e65cbd17ff569be43c0d3d2b4212c1ad5a91563b4111088caa5d50bee25" }, "downloads": -1, "filename": "python-ddp-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8a4a847ecba5cb86c8ae8c288d12de36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4527, "upload_time": "2014-06-25T22:45:12", "url": "https://files.pythonhosted.org/packages/54/6e/3f28e74ba7fd29da987804e2bc92bc30dd375ab3455b06993bce04f18a69/python-ddp-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b60b20ffeb701354cb2186a3225b4aa8", "sha256": "6e394fe8bbcbc3482e637ec3fe25550b2ee050f8b6303afe3ffd3b94309e21dd" }, "downloads": -1, "filename": "python-ddp-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b60b20ffeb701354cb2186a3225b4aa8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5056, "upload_time": "2014-07-10T21:55:03", "url": "https://files.pythonhosted.org/packages/cd/f2/4f6be672996e357ec00f9bcd48d45df92a782044d6ca4de90de58baac910/python-ddp-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "f220214e18197d21176338ee3d60455c", "sha256": "c7690814c3751fd3b285af0b10dab6dbfec0ae85e6b9f75ce4dd6862f4c9a990" }, "downloads": -1, "filename": "python-ddp-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f220214e18197d21176338ee3d60455c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5181, "upload_time": "2014-08-21T17:32:29", "url": "https://files.pythonhosted.org/packages/33/47/214f8870ce26c3f7905e1116f7cbb1f2086e3b7299a6bb04f861002e8891/python-ddp-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "9f27a156f06ed6262716a5397f54267d", "sha256": "344494cc3190f25aa9101b36028ca5edd65df2c72c8f7f10d0223e82b95c7ae8" }, "downloads": -1, "filename": "python-ddp-0.1.3.tar.gz", "has_sig": false, "md5_digest": "9f27a156f06ed6262716a5397f54267d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5554, "upload_time": "2014-11-20T16:31:22", "url": "https://files.pythonhosted.org/packages/cc/67/b030397eb7fc3cbdb149009e9575e6c58700f757596f23b3dd3fb47e5cf7/python-ddp-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "bb4d750dd48b88104f1d29604f1b603a", "sha256": "5b47e7556bcd000f5c89d510acdb6b5f5795626ab0c40bea7b5e4772b3ce7bd2" }, "downloads": -1, "filename": "python-ddp-0.1.4.tar.gz", "has_sig": false, "md5_digest": "bb4d750dd48b88104f1d29604f1b603a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5384, "upload_time": "2015-02-08T22:02:24", "url": "https://files.pythonhosted.org/packages/fc/40/864a69589f499fc5d7b862331b2c197855ae5c56cc7aa1fe344e38268eca/python-ddp-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "df80774a52f84258154c9371b6acf48d", "sha256": "1420f23e89c4ac378ba2f4b311ddcd032e0f0af4f79f8b0829cfad972d2e588f" }, "downloads": -1, "filename": "python-ddp-0.1.5.tar.gz", "has_sig": false, "md5_digest": "df80774a52f84258154c9371b6acf48d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6032, "upload_time": "2015-04-04T00:59:05", "url": "https://files.pythonhosted.org/packages/94/80/57c61ed3a7cab01618290ee48f173da9fb8671f2dc90e8a9c8d25ed44456/python-ddp-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "df80774a52f84258154c9371b6acf48d", "sha256": "1420f23e89c4ac378ba2f4b311ddcd032e0f0af4f79f8b0829cfad972d2e588f" }, "downloads": -1, "filename": "python-ddp-0.1.5.tar.gz", "has_sig": false, "md5_digest": "df80774a52f84258154c9371b6acf48d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6032, "upload_time": "2015-04-04T00:59:05", "url": "https://files.pythonhosted.org/packages/94/80/57c61ed3a7cab01618290ee48f173da9fb8671f2dc90e8a9c8d25ed44456/python-ddp-0.1.5.tar.gz" } ] }