1 from six import text_type |
1 from six import text_type |
2 |
|
3 from cubicweb.server.session import hooks_control |
|
4 |
2 |
5 for uri, cfg in config.read_sources_file().items(): |
3 for uri, cfg in config.read_sources_file().items(): |
6 if uri in ('system', 'admin'): |
4 if uri in ('system', 'admin'): |
7 continue |
5 continue |
8 repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg.copy()) |
6 repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg.copy()) |
9 |
7 |
10 add_entity_type('CWSource') |
8 add_entity_type('CWSource') |
11 add_relation_definition('CWSource', 'cw_source', 'CWSource') |
9 add_relation_definition('CWSource', 'cw_source', 'CWSource') |
12 add_entity_type('CWSourceHostConfig') |
10 add_entity_type('CWSourceHostConfig') |
13 |
11 |
14 with hooks_control(session, session.HOOKS_ALLOW_ALL, 'cw.sources'): |
12 with session.allow_all_hooks_but('cw.sources'): |
15 create_entity('CWSource', type=u'native', name=u'system') |
13 create_entity('CWSource', type=u'native', name=u'system') |
16 commit() |
14 commit() |
17 |
15 |
18 sql('INSERT INTO cw_source_relation(eid_from,eid_to) ' |
16 sql('INSERT INTO cw_source_relation(eid_from,eid_to) ' |
19 'SELECT e.eid,s.cw_eid FROM entities as e, cw_CWSource as s ' |
17 'SELECT e.eid,s.cw_eid FROM entities as e, cw_CWSource as s ' |