author | Julien Cristau <julien.cristau@logilab.fr> |
Wed, 14 Oct 2015 16:18:25 +0200 | |
changeset 10805 | de4403644b1c |
parent 10684 | 7e9c9a32f24f |
child 10907 | 9ae707db5265 |
permissions | -rw-r--r-- |
10684
7e9c9a32f24f
[py3k] unicode → six.text_type
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9460
diff
changeset
|
1 |
from six import text_type |
7e9c9a32f24f
[py3k] unicode → six.text_type
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9460
diff
changeset
|
2 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
3 |
from cubicweb.server.session import hooks_control |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
4 |
|
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8694
diff
changeset
|
5 |
for uri, cfg in config.read_sources_file().items(): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
6 |
if uri in ('system', 'admin'): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
7 |
continue |
6945
28bf94d062a9
[sources] refactor source creation and options handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6546
diff
changeset
|
8 |
repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg.copy()) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
9 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
10 |
add_entity_type('CWSource') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
11 |
add_relation_definition('CWSource', 'cw_source', 'CWSource') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
12 |
add_entity_type('CWSourceHostConfig') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
13 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
14 |
with hooks_control(session, session.HOOKS_ALLOW_ALL, 'cw.sources'): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
15 |
create_entity('CWSource', type=u'native', name=u'system') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
16 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
17 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
18 |
sql('INSERT INTO cw_source_relation(eid_from,eid_to) ' |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
19 |
'SELECT e.eid,s.cw_eid FROM entities as e, cw_CWSource as s ' |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
20 |
'WHERE s.cw_name=e.type') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
21 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
22 |
|
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8694
diff
changeset
|
23 |
for uri, cfg in config.read_sources_file().items(): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
24 |
if uri in ('system', 'admin'): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
25 |
continue |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
26 |
repo.sources_by_uri.pop(uri) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
27 |
config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items() |
6546
31586c7b63f6
[3.10 migration] must skip None values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6488
diff
changeset
|
28 |
if key != 'adapter' and value is not None) |
10684
7e9c9a32f24f
[py3k] unicode → six.text_type
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9460
diff
changeset
|
29 |
create_entity('CWSource', name=text_type(uri), type=text_type(cfg['adapter']), |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
30 |
config=config) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
31 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
32 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
# rename cwprops for boxes/contentnavigation |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
for x in rql('Any X,XK WHERE X pkey XK, ' |
7508
48398bf8a33a
fix 3.10 cwproperties migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6945
diff
changeset
|
35 |
'X pkey ~= "boxes.%" OR ' |
48398bf8a33a
fix 3.10 cwproperties migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6945
diff
changeset
|
36 |
'X pkey ~= "contentnavigation.%"').entities(): |
8483
4ba11607d84a
[entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7508
diff
changeset
|
37 |
x.cw_set(pkey=u'ctxcomponents.' + x.pkey.split('.', 1)[1]) |
6378
5a86a0c147bd
[3.10 migration] fix migration of cwproperties related to components/boxes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
38 |