This module provide a common interface for all CouchDB request. This module make HTTP request using httplib2 module.
Example:
>>> resource = CouchdbResource()
>>> info = resource.get()
>>> info['couchdb']
u'Welcome'
Constructor for a CouchdbResource object.
CouchdbResource represent an HTTP resource to CouchDB.
Parameters: |
|
---|
if you want to add a path to resource uri, you can do:
resr2 = res.clone()
if you want to add a path to resource uri, you can do:
Resource("/path").get()
Perform HTTP call to the couchdb server and manage JSON conversions, support GET, POST, PUT and DELETE.
Usage example, get infos of a couchdb server on http://127.0.0.1:5984 :
import simplecouchdb.CouchdbResource
resource = simplecouchdb.CouchdbResource()
infos = resource.request('GET'))
Parameters: |
|
---|---|
Returns: | tuple (data, resp), where resp is an httplib2.Response object and data a python object (often a dict). |
HTTP GET
Parameters: |
|
---|
HTTP HEAD
see GET for params description.
HTTP DELETE
see GET for params description.
HTTP POST
Parameters: |
|
---|
HTTP PUT
see POST for params description.
Exception raised when an unexpected HTTP error is received in response to a request.
The request failed, meaning the remote HTTP server returned a code other than success, unauthorized, or NotFound.
The exception message attempts to extract the error
You can get the status code by e.http_code, or see anything about the response via e.response. For example, the entire result body (which is probably an HTML error page) is e.response.body.
See also