7 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
8 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
9 """ |
9 """ |
10 |
10 |
11 applcubicwebversion, cubicwebversion = versions_map['cubicweb'] |
11 applcubicwebversion, cubicwebversion = versions_map['cubicweb'] |
|
12 |
|
13 if applcubicwebversion < (3, 4, 0) and cubicwebversion >= (3, 4, 0): |
|
14 from cubicweb.server.hooks import uniquecstrcheck_before_modification |
|
15 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_update_entity', '') |
|
18 add_relation_type('cwuri') |
|
19 base_url = session.base_url() |
|
20 # use an internal session since some entity might forbid modifications to admin |
|
21 isession = repo.internal_session() |
|
22 for eid, in rql('Any X', ask_confirm=False): |
|
23 isession.execute('SET X cwuri %(u)s WHERE X eid %(x)s', |
|
24 {'x': eid, 'u': base_url + u'eid/%s' % eid}) |
|
25 isession.commit() |
|
26 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
|
27 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
12 |
28 |
13 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |
29 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |
14 from base64 import b64encode |
30 from base64 import b64encode |
15 for table in ('entities', 'deleted_entities'): |
31 for table in ('entities', 'deleted_entities'): |
16 for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL' |
32 for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL' |