コード例 #1
0
def from0to1(registry):
    class Request(object):
        def __init__(self, registry):
            self.registry = registry

    len(registry.db.view('contracts/all', limit=1))
    results = registry.db.iterview('contracts/all',
                                   2**10,
                                   include_docs=True,
                                   stale='update_after')
    docs = []
    request = Request(registry)
    root = Root(request)
    for i in results:
        doc = i.doc
        if doc.get('documents'):
            contract = Contract(doc)
            contract.__parent__ = root
            doc = contract.to_primitive()
            docs.append(doc)
        if len(docs) >= 2**7:
            registry.db.update(docs)
            docs = []
    if docs:
        registry.db.update(docs)
コード例 #2
0
ファイル: migration.py プロジェクト: lttga/op2
def from1to2(registry):
    class Request(object):
        def __init__(self, registry):
            self.registry = registry

    len(registry.db.view("contracts/all", limit=1))
    results = registry.db.iterview("contracts/all",
                                   2**10,
                                   include_docs=True,
                                   stale="update_after")
    docs = []
    request = Request(registry)
    root = Root(request)
    for i in results:
        doc = i.doc
        if not all([
                i.get("url", "").startswith(registry.docservice_url)
                for i in doc.get("documents", [])
        ]):
            contract = Contract(doc)
            contract.__parent__ = root
            doc = contract.to_primitive()
            doc["dateModified"] = get_now().isoformat()
            docs.append(doc)
        if len(docs) >= 2**7:
            registry.db.update(docs)
            docs = []
    if docs:
        registry.db.update(docs)
コード例 #3
0
def from1to2(registry):
    class Request(object):
        def __init__(self, registry):
            self.registry = registry
    len(registry.db.view('contracts/all', limit=1))
    results = registry.db.iterview('contracts/all', 2 ** 10, include_docs=True, stale='update_after')
    docs = []
    request = Request(registry)
    root = Root(request)
    for i in results:
        doc = i.doc
        if not all([i.get('url', '').startswith(registry.docservice_url) for i in doc.get('documents', [])]):
            contract = Contract(doc)
            contract.__parent__ = root
            doc = contract.to_primitive()
            doc['dateModified'] = get_now().isoformat()
            docs.append(doc)
        if len(docs) >= 2 ** 7:
            registry.db.update(docs)
            docs = []
    if docs:
        registry.db.update(docs)