Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f985d430d4
Fetching contributors…

Cannot retrieve contributors at this time

file 632 lines (415 sloc) 21.508 kb

API Reference

This module consists of two different classes indicating query result, :class:`TrombiObject` and :class:`TrombiError`, first for the succesful API response and the latter for errorneus API response. All classes representing different data objects of CouchDB subclass :class:`TrombiObject`.

Helper methods

Result objects

A common error class indicating that an error has happened

Returned upon errorneus CouchDB API call. This is generally a call that results in other than 2xx response code.

Subclasses :class:`TrombiError`.

Returned upon succesful CouchDB call. This is also superclass for all data object classes presented below.

A generic result indicating a succesfull call. Used for example in :meth:`Database.list`. Subclasses :class:`TrombiObject`.

A dict-like object for successful responses. Subclasses :class:`TrombiObject`.

A special result object that represents a succesful view result. Subclasses :class:`TrombiObject` and :class:`collections.Sequence`.

Due to the subclassing of :class:`collections.Sequence`, behaves kind of like a tuple. Supports :func:`len`, accessing items with dictionary like syntax and iterating over result rows using :func:`iter`.

A special result object for CouchDB's bulk API responses. Subclasses :class:`TrombiObject` and :class:`collections.Sequence`.

Due to the subclassing of :class:`collections.Sequence`, behaves kind of like a tuple. Supports :func:`len`, accessing items with dictionary like syntax and iterating over result :func:`iter`.

A special result object for a single successful CouchDB's bulk API response. Subclasses :class:`TrombiObject` and :class:`collections.Mapping`.

Due to the subclassing of :class:`collections.Mapping`, behaves like a immutable dictionary. Can be converted to a dictionary object using built-in function :func:`dict`.

Indicates a single error response from bulk API. Subclasses :class:`TrombiError`.

Server

In case of an error, if not otherwise mentioned, all the following methods call callback function with :class:`TrombiError` as an argument.

Represents the connection to a CouchDB server. Subclass of :class:`TrombiObject`.

Has one required argument baseurl which is an URI to CouchDB database. If the baseurl ends in a slash (/), it is removed.

To ease testing a custom :class:`tornado.ioloop.IOLoop` instance can be passed as a keyword argument.

Database

In case of an error, if not otherwise mentioned, all the following methods call callback function with :class:`TrombiError` as an argument.

Represents a CouchDB database. Has two required argument, server and name where server denotes the :class:`Server` where database is and name is the name of the database.

Normally there's no need to create :class:`Database` objects as they are created via :meth:`Server.create` and :meth:`Server.get`. Subclass of :class:`TrombiObject`.

Document

In case of an error, if not otherwise mentioned, all the following methods call callback function with :class:`TrombiError` as an argument.

This class represents a CouchDB document. This subclasses both :class:`collections.MutableMapping` and :class:`TrombiObject`. Has two mandatory arguments, a :class:`Database` intance db and data, which is a representation of document data as :class:`dict`.

Normally there's no need to create Document objects as they are received as results of several different :class:`Database` operations.

Document behaves like a :class:`dict` (not exactly, but not far anyway), as it implements an abstract base class :class:`collections.MutableMapping`.

It supports :func:`len`, setting and getting values using the similiar notation as in dictionaries, e.g. doc[key] = val. It also implements :func:`__contains__` so the presence of a key can be inspected using in operator.

Paginator

Represents a pseudo-page of documents returned from a CouchDB view calculated from total_rows and offset as well as a user-defined page limit.

The one mandatory argument, db, is a :class:`Database` instance.

Something went wrong with that request. Please try again.