cubicweb/misc/migration/3.10.0_Any.py
branch3.25
changeset 12142 db2fc87348ab
parent 11279 e4f11ef1face
child 12567 26744ad37953
equal deleted inserted replaced
12141:29d032bb70d8 12142:db2fc87348ab
     1 from six import text_type
     1 from six import text_type
     2 
       
     3 for uri, cfg in config.read_sources_file().items():
       
     4     if uri in ('system', 'admin'):
       
     5         continue
       
     6     repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg.copy())
       
     7 
     2 
     8 add_entity_type('CWSource')
     3 add_entity_type('CWSource')
     9 add_relation_definition('CWSource', 'cw_source', 'CWSource')
     4 add_relation_definition('CWSource', 'cw_source', 'CWSource')
    10 add_entity_type('CWSourceHostConfig')
     5 add_entity_type('CWSourceHostConfig')
    11 
     6 
    19 commit()
    14 commit()
    20 
    15 
    21 for uri, cfg in config.read_sources_file().items():
    16 for uri, cfg in config.read_sources_file().items():
    22     if uri in ('system', 'admin'):
    17     if uri in ('system', 'admin'):
    23         continue
    18         continue
    24     repo.sources_by_uri.pop(uri)
       
    25     config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items()
    19     config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items()
    26                         if key != 'adapter' and value is not None)
    20                         if key != 'adapter' and value is not None)
    27     create_entity('CWSource', name=text_type(uri), type=text_type(cfg['adapter']),
    21     create_entity('CWSource', name=text_type(uri), type=text_type(cfg['adapter']),
    28                   config=config)
    22                   config=config)
    29 commit()
    23 commit()