couchclient

A light-weight, read-only CouchDB client
Download

couchclient Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Gavin M. Roy
  • Publisher web site:
  • http://area51.myyearbook.com/trac.cgi/wiki/Staplr

couchclient Tags


couchclient Description

couchclient is a light-weight CouchDB client for read-only requests of documents and views. It is not meant to be a full-featured client library or replacement for couchdb-python. Instead the focus is on being a read-only view of documents that would not necessarily be represented as CouchDB documents to the application requesting them.By default it strips couchdbisms ("_id", "_rev") from documents.Views are transformed to a dictionary from the CouchDB return representation to key-value pairs from the view. For example if a view is returned from CouchDB as:{ "total_rows": 2, "offset": 0, "rows": }CouchDB.get_view will return a dictionary of:{'abc': {'baz': 'qux', 'foo': 'bar'}, 'corge': {'baz': 'garply', 'foo': 'grault'}}Examplesimport couchclient# Create a new client, if you use a SSL port, it will use the proper schemeconfig = couchclient.CouchDB('couchdb.myhost.com', 5984, 'my_database')# Get a single documentdocument = config.get_document('my_document')print document# Fetch a viewconfig = couchclient.CouchDB('couchdb.myhost.com', 5984, 'my_database')messages = config.get_view('my_view_document', 'my_view')print messagesAPIclass CouchDB(__builtin__.object) | The CouchDB object creates a light-weight read-only client for CouchDB | for retrieving documents and views. | | Methods defined here: | | __init__(self, host, port, database) | Create a new configuration object for the given service and domain | name. | | :param str host: The FQDN needed to make requests to the CouchDB server | :param str port: The port to query CouchDB on | :param str database: The database name for CouchDB requests | | get_document(self, document_id) | Retrieve the document from the CouchDB server. | | :param str document_id: The document id to fetch | :returns: dict | :raises: DocumentNotFound | :raises: DocumentRetrievalFailure | | get_view(self, document_id, view_name) | Retrieve the view rows from the CouchDB server returning a dictionary | of key value pairs as taken from the view rows keyed on the row key. | | :param str document_id: The document_id with views | :param str view_name: The name of the view in the document | :returns: dict | :raises: DocumentNotFound | :raises: DocumentRetrievalFailure | | strip_couch_attributes(self) | Enable the stripping of CouchDB attributes (_id, _rev) on document | retrieval. | | strip_couch_attributes_off(self) | Disable the stripping of CouchDB attributes (_id, _rev) on document | retrieval.class DocumentNotFound(exceptions.EnvironmentError) | # Define exceptions that may be raised | | Method resolution order: | DocumentNotFound | exceptions.EnvironmentError | exceptions.StandardError | exceptions.Exception | exceptions.BaseException | __builtin__.object | | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.EnvironmentError: | | errno | exception errno | | filename | exception filename | | strerror | exception strerror | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class DocumentRetrievalFailure(exceptions.EnvironmentError) | Raised when a document was not retrieved from the CouchDB Server | | Method resolution order: | DocumentRetrievalFailure | exceptions.EnvironmentError | exceptions.StandardError | exceptions.Exception | exceptions.BaseException | __builtin__.object | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.EnvironmentError: | | errno | exception errno | | filename | exception filename | | strerror | exception strerror | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | messageProduct's homepage


couchclient Related Software