couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Couchdb Wiki] Update of "Getting_started_with_Python" by JohannPhilippStrathausen
Date Mon, 29 Nov 2010 11:43:19 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Getting_started_with_Python" page has been changed by JohannPhilippStrathausen.


  Demonstration of basic API-interaction using Python. (note: as of python 2.6, one can use
"import json" for the same functionality in this script.)
- #! /usr/bin/python2.4
+ #! /usr/bin/python2.6
+ import httplib, json
- import httplib, simplejson  #
-                             # Here only used for prettyprinting
  def prettyPrint(s):
      """Prettyprints the json response of an HTTPResponse object"""
      # HTTPResponse instance -> Python object -> str
-     print simplejson.dumps(simplejson.loads(, sort_keys=True, indent=4)
+     print simplejson.dumps(json.loads(, sort_keys=True, indent=4)
  class Couch:
      """Basic wrapper class for operations on a couchDB"""
@@ -118, +117 @@

          # XXX Crashed if resource is non-existent; not so for DELETE on db. Bug?
          # XXX Does not work any more, on has to specify an revid
          #     Either do html head to get the recten revid or provide it as parameter
-         r = self.delete(''.join(['/', dbName, '/', docId]))
+         r = self.delete(''.join(['/', dbName, '/', docId, '?revid=', rev_id]))
      # Basic http methods

View raw message