misc/migration/bootstrapmigration_repository.py
changeset 2696 b45d852990d5
parent 2578 b717ebef04d8
child 2892 7ae3d62a8328
child 2955 6bb5025c9fc7
equal deleted inserted replaced
2695:56439c45781c 2696:b45d852990d5
    19     add_relation_type('cwuri')
    19     add_relation_type('cwuri')
    20     base_url = session.base_url()
    20     base_url = session.base_url()
    21     # use an internal session since some entity might forbid modifications to admin
    21     # use an internal session since some entity might forbid modifications to admin
    22     isession = repo.internal_session()
    22     isession = repo.internal_session()
    23     for eid, in rql('Any X', ask_confirm=False):
    23     for eid, in rql('Any X', ask_confirm=False):
    24         try:
    24         type, source, extid = session.describe(eid)
       
    25         if source == 'system':
    25             isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s',
    26             isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s',
    26                              {'x': eid, 'u': base_url + u'eid/%s' % eid})
    27                              {'x': eid, 'u': base_url + u'eid/%s' % eid})
    27         except RepositoryError:
       
    28             print 'unable to set cwuri for', eid, session.describe(eid)
       
    29     isession.commit()
    28     isession.commit()
    30     repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '')
    29     repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '')
    31     repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '')
    30     repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '')
    32     session.set_shared_data('do-not-insert-cwuri', False)
    31     session.set_shared_data('do-not-insert-cwuri', False)
    33 
    32