cubicweb/misc/migration/3.10.0_Any.py
changeset 12567 26744ad37953
parent 12142 db2fc87348ab
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
     1 from six import text_type
       
     2 
       
     3 add_entity_type('CWSource')
     1 add_entity_type('CWSource')
     4 add_relation_definition('CWSource', 'cw_source', 'CWSource')
     2 add_relation_definition('CWSource', 'cw_source', 'CWSource')
     5 add_entity_type('CWSourceHostConfig')
     3 add_entity_type('CWSourceHostConfig')
     6 
     4 
     7 with session.allow_all_hooks_but('cw.sources'):
     5 with session.allow_all_hooks_but('cw.sources'):
    16 for uri, cfg in config.read_sources_file().items():
    14 for uri, cfg in config.read_sources_file().items():
    17     if uri in ('system', 'admin'):
    15     if uri in ('system', 'admin'):
    18         continue
    16         continue
    19     config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items()
    17     config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items()
    20                         if key != 'adapter' and value is not None)
    18                         if key != 'adapter' and value is not None)
    21     create_entity('CWSource', name=text_type(uri), type=text_type(cfg['adapter']),
    19     create_entity('CWSource', name=uri, type=cfg['adapter'],
    22                   config=config)
    20                   config=config)
    23 commit()
    21 commit()
    24 
    22 
    25 # rename cwprops for boxes/contentnavigation
    23 # rename cwprops for boxes/contentnavigation
    26 for x in rql('Any X,XK WHERE X pkey XK, '
    24 for x in rql('Any X,XK WHERE X pkey XK, '