author | Julien Cristau <julien.cristau@logilab.fr> |
Mon, 21 Mar 2016 18:08:47 +0100 | |
changeset 11223 | d4d36b583f40 |
parent 11178 | b3d3e23be27b |
child 11278 | 19fcce6dc6d1 |
permissions | -rw-r--r-- |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
1 |
|
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8694
diff
changeset
|
2 |
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
|
3 |
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
|
4 |
continue |
6945
28bf94d062a9
[sources] refactor source creation and options handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6546
diff
changeset
|
5 |
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
|
6 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
7 |
add_entity_type('CWSource') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
8 |
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
|
9 |
add_entity_type('CWSourceHostConfig') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
10 |
|
11178
b3d3e23be27b
[migration/3.10] fix AttributeError
Julien Cristau <julien.cristau@logilab.fr>
parents:
9460
diff
changeset
|
11 |
with session.allow_all_hooks_but('cw.sources'): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
12 |
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
|
13 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
14 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
15 |
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
|
16 |
'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
|
17 |
'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
|
18 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
19 |
|
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8694
diff
changeset
|
20 |
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
|
21 |
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
|
22 |
continue |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
if key != 'adapter' and value is not None) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
26 |
create_entity('CWSource', name=unicode(uri), type=unicode(cfg['adapter']), |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
27 |
config=config) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
28 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
29 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
# 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
|
31 |
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
|
32 |
'X pkey ~= "boxes.%" OR ' |
48398bf8a33a
fix 3.10 cwproperties migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6945
diff
changeset
|
33 |
'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
|
34 |
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
|
35 |