{ "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-meteor\n\nAn event driven Meteor client\n\n**Installation**\n\n```bash\n$ pip install python-meteor\n```\n\n**Table of Contents**\n\n- [History](#history)\n- [TODO](#TODO)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n- [Example](#example)\n- [Collaborators](#collaborators)\n\n## History\n\n**Latest Version** 0.1.6\n\n- Add support for meteor login resume tokens (thanks [@ppettit](https://github.com/ppettit))\n\n**Version** 0.1.5\n\n- BUGFIX - unsubscribe was not unsubcribing (missing sub ID) (thanks [@tdamsma](https://github.com/tdamsma))\n- examples and docs support python 3\n\n**Version** 0.1.4\n\n- BUGFIX - update connected status when reconnecting (thanks [@ppettit](https://github.com/ppettit))\n- BUGFIX - make sure `logged_in` callback get's fired (thanks [@pmgration](https://github.com/pmgration))\n- NOTE: python-ddp library has been updated that addresses connection problems\n\n**Version** 0.1.3\n\n- Fixed a bug that was causing a crash while removing a field on a change event (thanks [@ppettit](https://github.com/ppettit))\n\n**Version** 0.1.2\n\n- Implemented auto reconnect (auto reconnect on by default) and reconnected event emitter\n\n**Version** 0.1.1\n\n- Fixed bug in setup, was including built in hashlib\n\n**Version** 0.1.0\n\n- Initial implementation, add ability to call, subscribe, unsubscribe, do basic queries and login\n- Data is stored in a local python dictionary (in memory) and updated in real time as collection change events are received. This allows for very a basic find and find_one APIs to be implemented.\n\n## TODO\n\n- Full minimongo API for find and find_one\n- CI unit testing with Travis\n\n## Quick Start\n\n### General Commands\n\n**Create a Meteor client and connect**\n\n```python\nfrom MeteorClient import MeteorClient\n\nclient = MeteorClient('ws://127.0.0.1:3000/websocket')\nclient.connect()\n```\n\n**Establish A Connection Without Auto Reconnect**\n\n```python\nfrom MeteorClient import MeteorClient\n\nclient = MeteorClient('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 MeteorClient import MeteorClient\n# try to reconnect every second\nclient = MeteorClient('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\ndef callback_function(error, result):\n if error:\n print(error)\n return\n\n print(result)\n\nclient.call('someFunction', [1, 2, 3], callback_function)\n```\n\n**Subscribe and Unsubscribe**\n\n```python\ndef subscription_callback(error):\n if error:\n print(error)\n\nclient.subscribe('posts', callback=subscription_callback)\nclient.unsubscribe('posts')\n```\n\n**Find All Data In a Collection**\n\n```python\nall_posts = client.find('posts')\n```\n\n**Find Data In a Collection With Selector**\n\n```python\nsacha_posts = client.find('posts', selector={'author': 'Sacha Greif'})\n```\n\n**Find One**\n\n```python\none_post = client.find_one('posts')\n```\n\n**Fine One With Selector**\n\n```python\none_post = client.find_one('posts', selector={'author': 'Sacha Greif'})\n```\n\n**Insert**\n\n```python\ndef insert_callback(error, data):\n if error:\n print(error)\n return\n print(data)\n\nclient.insert('posts', {'title': 'Google', 'url': 'https://google.com', 'comments': 'Search'}, callback=insert_callback)\n```\n\n**Update**\n\n```python\ndef update_callback(error, data):\n if error:\n print(error)\n return\n print(data)\n\nclient.update('posts', {'title': 'Google'}, {'comments': 'Google main page'}, callback=update_callback)\n```\n\n**Remove**\n\n```python\ndef remove_callback(error, data):\n if error:\n print(error)\n return\n print(data)\n\nclient.remove('posts', {'title': 'Google'}, callback=remove_callback)\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####connect()\n\nConnect to the meteor server\n\n####login(user, password, token=token, callback=None)\n\nLogin with a username and password. If a token is provided it will be tried first, falling back to username and password if\nthe token is invalid.\n\n**Arguments**\n\n_user_ - username or email address \n_password_ - the password for the account \n\n**Keyword Arguments**\n\n_token_ - meteor resume token\n_callback_ - callback function containing error as first argument and login data \n\n####logout(callback=None)\n\nLogout a user\n\n**Keyword Arguments**\n\n_callback_ - callback function called when the user has been logged out \n\n#### call(method, params, callback=None)\n\nCall a remote method\n\n**Arguments**\n\n_method_ - remote method name \n_params_ - remote method parameters \n\n**Keyword Arguments**\n\n_callback_ - callback function containing return data \n\n#### subscribe(name, params=[], callback=None)\n\nSubscribe to a collection\n\n**Arguments**\n\n_name_ - the name of the publication \n_params_ - the subscription parameters \n\n**Keyword Arguments**\n\n_callback_ - a function callback that returns an error (if exists) \n\n####unsubscribe(name)\n\nUnsubscribe from a collection\n\n**Arguments**\n\n_name_ - the name of the publication \n\n####find(collection, selector={})\n\nFind data in a collection\n\n**Arguments**\n\n_collection_ - collection to search \n\n**Keyword Arguments**\n\n_selector_ - the query (default returns all items in a collection) \n\n####find_one(collection, selector={})\n\nReturn one item from a collection\n\n**Arguments**\n\n_collection_ - collection to search \n\n**Keyword Arguments**\n\n_selector_ - the query (default returns first item found) \n\n####insert(collection, doc, callback=None)\n\nInsert an item into a collection\n\n**Arguments**\n\n_collection_ - the collection to be modified \n_doc_ - The document to insert. May not yet have an _id attribute, \nin which case Meteor will generate one for you. \n\n**Keyword Arguments**\n\n_callback_ - Optional. If present, called with an error object as the first argument and, \nif no error, the _id as the second. \n\n####update(collection, selector, modifier, callback=None)\n\nInsert an item into a collection\n\n**Arguments**\n\n_collection_ - the collection to be modified \n_selector_ - specifies which documents to modify \n_modifier_ - Specifies how to modify the documents \n\n**Keyword Arguments**\n\n_callback_ - Optional. If present, called with an error object as the first argument and, \nif no error, the number of affected documents as the second. \n\n####remove(collection, selector, callback=None)\n\nRemove an item from a collection\n\n**Arguments**\n\n_collection_ - the collection to be modified \n_selector_ - Specifies which documents to remove \n\n**Keyword Arguments**\n\n_callback_ - Optional. If present, called with an error object as its argument. \n\n### Events and Callback Arguments\n\nWhen creating an instance of `MeteorClient` 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 MeteorClient import MeteorClient\nclient = MeteorClient('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#### 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('closed', closed)\n```\n\n`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#### 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(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#### subscribed\n\nRegister the event to a callback function\n\n```python\ndef subscribed(subscription):\n print('* SUBSCRIBED {}'.format(subscription))\n\nclient.on('subscribed', subscribed)\n```\n\n`subscribed` callback takes the following arguments\n\n_subscription_ - the name of the subscription\n\n#### unsubscribed\n\nRegister the event to a callback function\n\n```python\ndef unsubscribed(subscription):\n print('* UNSUBSCRIBED {}'.format(subscription))\n\nclient.on('unsubscribed', unsubscribed)\n```\n\n`unsubscribed` callback takes the following arguments\n\n_subscription_ - the name of the subscription\n\n#### logging_in\n\nRegister the event to a callback function\n\n```python\ndef logging_in():\n print('* LOGGIN IN')\n\nclient.on('logging_in', logging_in)\n```\n\n`logging_in` callback takes no arguments\n\n#### logged_in\n\nRegister the event to a callback function\n\n```python\ndef logged_in(data):\n print('* LOGGED IN {}'.format(data))\n\nclient.on('logged_in', logged_in)\n```\n\n`logged_in` callback takes the following arguments\n\n_data_ - login return data\n\n#### logged_out\n\nRegister the event to a callback function\n\n```python\ndef logged_out():\n print('* LOGGED OUT')\n\nclient.on('logged_out', logged_out)\n```\n\n`logged_out` callback takes no arguments\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('added', added)\nclient.on('changed', changed)\nclient.on('removed', removed)\nclient.on('subscibed', subscibed)\nclient.on('unsubscribed', unsubscribed)\nclient.on('logging_in', logging_in)\nclient.on('logged_in', logged_in)\nclient.on('logged_out', logged_out)\n```\n\n##Example\n\nThere is an included `example.py` script to use with the `todo` sample app included with meteor\n\nCreate the sample meteor app and start it\n\n```bash\n$ meteor create --example todos\n$ meteor\n```\n\nThen run example.py\n\n```bash\n$ python example.py\n```\n\n##Collaborators\n\n- [@ppettit](https://github.com/ppettit)\n- [@pmgration](https://github.com/pmgration)\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-meteor", "keywords": "meteor,ddp,events,emitter,node.js,node,eventemitter,event_emitter,ejson", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "python-meteor", "package_url": "https://pypi.org/project/python-meteor/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-meteor/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/hharnisc/python-meteor" }, "release_url": "https://pypi.org/project/python-meteor/0.1.6/", "requires_dist": null, "requires_python": null, "summary": "An event driven meteor client", "version": "0.1.6" }, "last_serial": 1534140, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "c0d7c507b62bbccac8bd66fecd19f14a", "sha256": "0bcd6532a64fd6ce23a52a4056b8cb70bfe4386ac8c9dddb778e4651b58517e9" }, "downloads": -1, "filename": "python-meteor-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c0d7c507b62bbccac8bd66fecd19f14a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6192, "upload_time": "2014-06-29T04:15:36", "url": "https://files.pythonhosted.org/packages/f6/4d/22d7bed95a12567078edd650e614742c3972f6758ca9451a1f83695fd83a/python-meteor-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7bfc08a06b7e8eb0508ba9b59a03c74e", "sha256": "2b6830571eaee3a355db542deb84e30c66455554333237e185a40c3fc25873b5" }, "downloads": -1, "filename": "python-meteor-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7bfc08a06b7e8eb0508ba9b59a03c74e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6186, "upload_time": "2014-07-01T16:52:42", "url": "https://files.pythonhosted.org/packages/27/83/62a4d03f3dc2a603f25e934700ae888de9aface5f3678238ecaa9ed0f409/python-meteor-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "69c995ad186b278047f23baec2ef2e96", "sha256": "ed08895d1b54a950038fbb535daaf1e58aefd251888fca8021ea083760dc3d38" }, "downloads": -1, "filename": "python-meteor-0.1.2.tar.gz", "has_sig": false, "md5_digest": "69c995ad186b278047f23baec2ef2e96", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6895, "upload_time": "2014-07-10T21:55:19", "url": "https://files.pythonhosted.org/packages/3a/c0/52d0554353d5d2fd768a68df3c013867fac4d6c7bf60cb1a78ac060471fb/python-meteor-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "27d13c88b88975159ad0d0bae5c4cc43", "sha256": "98fb36060c28faed13d721f0d2782653ee4d2c27bcac23d3b3bb981f78125cff" }, "downloads": -1, "filename": "python-meteor-0.1.3.tar.gz", "has_sig": false, "md5_digest": "27d13c88b88975159ad0d0bae5c4cc43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7000, "upload_time": "2014-08-13T00:21:27", "url": "https://files.pythonhosted.org/packages/22/c6/468e8de57c8656d71f2ef5ad2cc093b80c4a47bc4b07b25687b2c10c008a/python-meteor-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "35eec6e231134dab6315420dbe679ecc", "sha256": "acb4829d96bf8d9f6a087210b267eb38397349a495959cee726f4c3b6efba8d2" }, "downloads": -1, "filename": "python-meteor-0.1.4.tar.gz", "has_sig": false, "md5_digest": "35eec6e231134dab6315420dbe679ecc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7308, "upload_time": "2015-02-08T22:19:35", "url": "https://files.pythonhosted.org/packages/05/87/4b4515cef34526fe358d611aea041c7075f26d5c2fe0895c8828082a56d7/python-meteor-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "0db16dd61cf193757facb8aa4a37a61a", "sha256": "702a7ada2d6f4a111cdf9118408fe3ef2319d72fdd0e68e33e42cf3b638ce44e" }, "downloads": -1, "filename": "python-meteor-0.1.5.tar.gz", "has_sig": false, "md5_digest": "0db16dd61cf193757facb8aa4a37a61a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7398, "upload_time": "2015-04-04T01:14:56", "url": "https://files.pythonhosted.org/packages/8d/b7/cb8899432120bce8a77769e740fd9198681592329d8347ec1a482f9e7369/python-meteor-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "a3aa0993f07fd941adddc44b91438ab8", "sha256": "014bd2fd61e73e8f67892a0114fbcb3185db3bc74f70990379aedb5b359a8667" }, "downloads": -1, "filename": "python-meteor-0.1.6.tar.gz", "has_sig": false, "md5_digest": "a3aa0993f07fd941adddc44b91438ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7656, "upload_time": "2015-05-05T15:44:50", "url": "https://files.pythonhosted.org/packages/0c/ac/53e6e025df93b8431c5bc4b0089aba75ebb48a030c91c17c52b12635b3be/python-meteor-0.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a3aa0993f07fd941adddc44b91438ab8", "sha256": "014bd2fd61e73e8f67892a0114fbcb3185db3bc74f70990379aedb5b359a8667" }, "downloads": -1, "filename": "python-meteor-0.1.6.tar.gz", "has_sig": false, "md5_digest": "a3aa0993f07fd941adddc44b91438ab8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7656, "upload_time": "2015-05-05T15:44:50", "url": "https://files.pythonhosted.org/packages/0c/ac/53e6e025df93b8431c5bc4b0089aba75ebb48a030c91c17c52b12635b3be/python-meteor-0.1.6.tar.gz" } ] }