Esempio n. 1
0
def add_works(akey, works):
    queue = []
    for w in works:
        w['key'] = next_work_key()
        q = {
            'authors': [akey],
            'create': 'unless_exists',
            'type': '/type/work',
            'key': w['key'],
            'title': w['title']
        }
        #queue.append(q)
        print(ol.write(q, comment='create work'))
        for ekey in w['editions']:
            e = ol.get(ekey)
            fix_edition(ekey, e, ol)
            e['works'] = [Reference(w['key'])]
            try:
                ol.save(ekey, e, 'found a work')
            except olapi.OLError:
                print(ekey)
                print(e)
                raise
Esempio n. 2
0
def add_works(akey, works):
    queue = []
    for w in works:
        w['key'] = next_work_key()
        q = {
            'authors': [akey],
            'create': 'unless_exists',
            'type': '/type/work',
            'key': w['key'],
            'title': w['title']
        }
        #queue.append(q)
        print(ol.write(q, comment='create work'))
        for ekey in w['editions']:
            e = ol.get(ekey)
            fix_edition(ekey, e, ol)
            e['works'] = [Reference(w['key'])]
            try:
                ol.save(ekey, e, 'found a work')
            except olapi.OLError:
                print(ekey)
                print(e)
                raise