9 """ |
9 """ |
10 |
10 |
11 applcubicwebversion, cubicwebversion = versions_map['cubicweb'] |
11 applcubicwebversion, cubicwebversion = versions_map['cubicweb'] |
12 |
12 |
13 if applcubicwebversion < (3, 4, 0) and cubicwebversion >= (3, 4, 0): |
13 if applcubicwebversion < (3, 4, 0) and cubicwebversion >= (3, 4, 0): |
|
14 from cubicweb import RepositoryError |
14 from cubicweb.server.hooks import uniquecstrcheck_before_modification |
15 from cubicweb.server.hooks import uniquecstrcheck_before_modification |
15 session.set_shared_data('do-not-insert-cwuri', True) |
16 session.set_shared_data('do-not-insert-cwuri', True) |
16 repo.hm.unregister_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
17 repo.hm.unregister_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
17 repo.hm.unregister_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
18 repo.hm.unregister_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
18 add_relation_type('cwuri') |
19 add_relation_type('cwuri') |
19 base_url = session.base_url() |
20 base_url = session.base_url() |
20 # 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 |
21 isession = repo.internal_session() |
22 isession = repo.internal_session() |
22 for eid, in rql('Any X', ask_confirm=False): |
23 for eid, in rql('Any X', ask_confirm=False): |
23 isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s', |
24 try: |
24 {'x': eid, 'u': base_url + u'eid/%s' % eid}) |
25 isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s', |
|
26 {'x': eid, 'u': base_url + u'eid/%s' % eid}) |
|
27 except RepositoryError: |
|
28 print 'unable to set cwuri for', eid, session.describe(eid) |
25 isession.commit() |
29 isession.commit() |
26 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
30 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
27 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
31 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
28 |
32 |
29 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |
33 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |