|
1 from cubicweb.server.session import hooks_control |
|
2 |
|
3 for uri, cfg in config.sources().items(): |
|
4 if uri in ('system', 'admin'): |
|
5 continue |
|
6 repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg) |
|
7 |
|
8 add_entity_type('CWSource') |
|
9 add_relation_definition('CWSource', 'cw_source', 'CWSource') |
|
10 add_entity_type('CWSourceHostConfig') |
|
11 |
|
12 with hooks_control(session, session.HOOKS_ALLOW_ALL, 'cw.sources'): |
|
13 create_entity('CWSource', type=u'native', name=u'system') |
|
14 commit() |
|
15 |
|
16 sql('INSERT INTO cw_source_relation(eid_from,eid_to) ' |
|
17 'SELECT e.eid,s.cw_eid FROM entities as e, cw_CWSource as s ' |
|
18 'WHERE s.cw_name=e.type') |
|
19 commit() |
|
20 |
|
21 for uri, cfg in config.sources().items(): |
|
22 if uri in ('system', 'admin'): |
|
23 continue |
|
24 repo.sources_by_uri.pop(uri) |
|
25 config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items() |
|
26 if key != 'adapter') |
|
27 create_entity('CWSource', name=unicode(uri), type=unicode(cfg['adapter']), |
|
28 config=config) |
|
29 commit() |
|
30 |
1 # rename cwprops for boxes/contentnavigation |
31 # rename cwprops for boxes/contentnavigation |
2 for x in rql('Any X,XK WHERE X pkey XK, ' |
32 for x in rql('Any X,XK WHERE X pkey XK, ' |
3 'X pkey ~= "boxes.%s" OR ' |
33 'X pkey ~= "boxes.%s" OR ' |
4 'X pkey ~= "contentnavigation.%s"').entities(): |
34 'X pkey ~= "contentnavigation.%s"').entities(): |
5 x.set_attributes(pkey=u'ctxcomponents.' + x.pkey.split('.', 1)[1]) |
35 x.set_attributes(pkey=u'ctxcomponents.' + x.pkey.split('.', 1)[1]) |