{ "info": { "author": "Christian Swinehart", "author_email": "drafting@samizdat.cc", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Database :: Front-Ends", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "==================================\r\nCorduroy \u00b7 asynchronous upholstery\r\n==================================\r\n:project: http://samizdat.cc/corduroy\r\n:code: http://github.com/samizdatco/corduroy\r\n\r\nAbout\r\n=====\r\n\r\nCorduroy provides a python-friendly wrapper around CouchDB\u2019s HTTP-based API.\r\nBehind the scenes it hooks into the asynchronous i/o routines from your choice\r\nof `Tornado `_ or the \r\n`Requests `_ & `Gevent `_ modules.\r\n\r\nUsing corduroy you can query the database without blocking your server\u2019s event\r\nloop, making it ideal for `CouchApp `_ micro-middleware \r\nor scripted batch operations.\r\n\r\nUsage\r\n=====\r\n\r\nAs a real world(ish) example of working with Corduroy, consider this pair of\r\nTornado event handlers which update a url-specifed document then query a view.\r\nThe first uses explicit callbacks to resume execution after each response from\r\nthe database is received::\r\n\r\n db = Database('players')\r\n class RankingsUpdater(tornado.web.RequestHandler):\r\n @tornado.web.asynchronous\r\n def post(self, player_id):\r\n self.new_score = int(self.request.body)\r\n db.get(player_id, callback=self.got_player)\r\n\r\n def got_player(doc, status):\r\n doc.score = self.new_score\r\n db.save(doc, callback=self.saved_player)\r\n\r\n def saved_player(conflicts, status):\r\n db.view('leaderboard/highscores', \r\n callback=self.got_highscores)\r\n\r\n def got_highscores(rows, status):\r\n self.write(json.dumps(rows))\r\n self.finish()\r\n\r\nAn alternative syntax is available (when using Tornado) through the use of the\r\n@relax decorator. Instead of defining callbacks for each database operation,\r\nthe library can be called as part of a yield expression.\r\n\r\nTornado\u2019s `generator `_ module \r\nwill intercept these yields and provide a callback automatically. The result is \r\ncode that looks quite sequential but will still execute asyncronously::\r\n\r\n class RankingsUpdater(tornado.web.RequestHandler):\r\n @relax\r\n def post(self, player_id):\r\n # update this player's score\r\n doc = yield db.get(player_id)\r\n doc.score = int(self.request.body)\r\n yield db.save(doc)\r\n\r\n # return the new rankings\r\n highscores = yield db.view('leaderboard/highscores')\r\n self.write(json.dumps(highscores))\r\n self.finish()\r\n\r\nFor a gentle introduction to Corduroy (and CouchDB in general), take a look at\r\nthe `Guide `_. Documentation for all of Corduroy\u2019s \r\nmodule-level classes can be found in the `Reference `_ \r\nsection.\r\n\r\nInstallation\r\n============\r\n\r\nAutomatic Installation\r\n----------------------\r\n\r\nCorduroy can be found on PyPi and can be installed with your choice of pip or\r\neasy_install.\r\n\r\nManual Installation\r\n-------------------\r\n\r\nDownload `corduroy-0.9.0.tar.gz `_::\r\n\r\n tar xvzf corduroy-0.9.0.tar.gz\r\n cd corduroy-0.9.0\r\n python setup.py install\r\n\r\nDependencies\r\n------------\r\n\r\nIf you\u2019re writing a Tornado app, Corduroy can use its pure-python HTTP client\r\nby installing with::\r\n\r\n pip install corduroy tornado\r\n\r\nOr if you\u2019d prefer the libcurl-based client (which supports pooling and other\r\nniceties), use::\r\n\r\n pip install corduroy tornado pycurl\r\n\r\nIf pycurl complains (I\u2019m looking at you, OS X), try::\r\n\r\n env ARCHFLAGS=\"-arch x86_64\" pip install pycurl\r\n\r\nGevent users can install with::\r\n\r\n pip install corduroy requests gevent\r\n\r\nThe library can also be used with plain-old blocking i/o::\r\n\r\n pip install corduroy requests\r\n\r\nLicense\r\n=======\r\n\r\nCorduroy is released under the BSD license. Use it freely and in good health.\r\n\r\nAcknowledgments\r\n===============\r\n\r\nCorduroy is derived from Christopher Lenz\u2019s excellent `couchdb-python\r\n`_ module and inherits much of its\r\nAPI (and most of its test cases) from that codebase. It is also indebted to\r\nEric Naeseth\u2019s mind-expanding `Swirl `_\r\nlibrary which first acquainted me with the idea of using generators to\r\nsimulate sequential code.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://samizdat.cc/corduroy", "keywords": "", "license": "Copyright (C) 2012 Samizdat Drafting Co.\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions\r\nare met:\r\n\r\n 1. Redistributions of source code must retain the above copyright\r\n notice, this list of conditions and the following disclaimer.\r\n 2. Redistributions in binary form must reproduce the above copyright\r\n notice, this list of conditions and the following disclaimer in\r\n the documentation and/or other materials provided with the\r\n distribution.\r\n 3. The name of the author may not be used to endorse or promote\r\n products derived from this software without specific prior\r\n written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\r\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\nARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\r\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\r\nGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\r\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r\nOTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\r\nIF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", "maintainer": "", "maintainer_email": "", "name": "corduroy", "package_url": "https://pypi.org/project/corduroy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/corduroy/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://samizdat.cc/corduroy" }, "release_url": "https://pypi.org/project/corduroy/0.9.0/", "requires_dist": null, "requires_python": null, "summary": "An asynchronous CouchDB client library", "version": "0.9.0" }, "last_serial": 400195, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "fad6434feedc75c67fc80f42b031c957", "sha256": "881c5c1570553bc29e9383a408e9ad39451a56f0a6ff696ca3b881cfa80aa93b" }, "downloads": -1, "filename": "corduroy-0.9.0.tar.gz", "has_sig": false, "md5_digest": "fad6434feedc75c67fc80f42b031c957", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 296306, "upload_time": "2012-04-03T20:38:09", "url": "https://files.pythonhosted.org/packages/19/df/1abe2f348cb946c0032aeec95cde0e1b270476fe7e7bef17d6259f49767f/corduroy-0.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fad6434feedc75c67fc80f42b031c957", "sha256": "881c5c1570553bc29e9383a408e9ad39451a56f0a6ff696ca3b881cfa80aa93b" }, "downloads": -1, "filename": "corduroy-0.9.0.tar.gz", "has_sig": false, "md5_digest": "fad6434feedc75c67fc80f42b031c957", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 296306, "upload_time": "2012-04-03T20:38:09", "url": "https://files.pythonhosted.org/packages/19/df/1abe2f348cb946c0032aeec95cde0e1b270476fe7e7bef17d6259f49767f/corduroy-0.9.0.tar.gz" } ] }