author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Mon, 11 Oct 2010 19:12:59 +0200 | |
changeset 6448 | 8590d82e9b1b |
parent 6427 | c8a5ac2d1eaa |
child 6488 | a512dd258ee8 |
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 |
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
|
2 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
3 |
for uri, cfg in config.sources().items(): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
4 |
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
|
5 |
continue |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
6 |
repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
7 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
8 |
add_entity_type('CWSource') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
9 |
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
|
10 |
add_entity_type('CWSourceHostConfig') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
11 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
12 |
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
|
13 |
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
|
14 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
15 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
16 |
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
|
17 |
'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
|
18 |
'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
|
19 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
20 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
21 |
for uri, cfg in config.sources().items(): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
22 |
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
|
23 |
continue |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
24 |
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
|
25 |
config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
26 |
if key != 'adapter') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
27 |
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
|
28 |
config=config) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
29 |
commit() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6378
diff
changeset
|
30 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
# 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
|
32 |
for x in rql('Any X,XK WHERE X pkey XK, ' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
'X pkey ~= "boxes.%s" OR ' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
'X pkey ~= "contentnavigation.%s"').entities(): |
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 |
x.set_attributes(pkey=u'ctxcomponents.' + x.pkey.split('.', 1)[1]) |
5a86a0c147bd
[3.10 migration] fix migration of cwproperties related to components/boxes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
36 |