コード例 #1
0
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)
コード例 #2
0
ファイル: fixup.py プロジェクト: SciLifeLab/slog
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
コード例 #3
0
ファイル: fixup.py プロジェクト: SciLifeLab/slog
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
コード例 #4
0
ファイル: load_instrumentrun.py プロジェクト: SciLifeLab/slog
def load_instrumentrun(name):
    db = configuration.get_db()
    if configuration.