def put_document(doc): "Add or update the given dictionary as a document." db = get_db() if not doc.has_key('_id'): doc['_id'] = utils.id_uuid() try: (id, rev) = db.save(doc) except couchdb.http.ResourceConflict: doc['_rev'] = db.revisions(doc['_id']).next().rev (id, rev) = db.save(doc) return (id, rev)
def for_all_documents(modify): """For all documents, apply the given function 'modify', which makes inline changes to the document, and returns the document if it was changed, or None if not. Return a list of tuples (id, rev) for all changed documents.""" db = configuration.get_db() result = [] for row in db.view('_all_docs'): doc = modify(db[row.id]) if doc: result.append(db.save(doc)) return result
def load_instrumentrun(name): db = configuration.get_db() if configuration.