cubicweb/misc/migration/3.10.0_Any.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Sat, 16 Jan 2016 13:48:51 +0100
changeset 11057 0b59724cb3f2
parent 10907 misc/migration/3.10.0_Any.py@9ae707db5265
child 11279 e4f11ef1face
permissions -rw-r--r--
Reorganize source tree to have a "cubicweb" top-level package Basically: mkdir cubicweb hg mv *.py -X setup.py cubicweb hg mv dataimport devtools entities etwist ext hooks i18n misc schemas server skeleton sobjects test web wsgi cubicweb Other changes: * adjust path to cubicweb-ctl in devtools tests * update setup.py to avoid importing __pkginfo__ (exec it instead), replace os.path.walk by os.walk and prepend `modname` here and there * update tox.ini to account for new test locations * update doc/conf.py so that it still finds __pkginfo__.py and CWDIR in doc/Makefile

from six import text_type

from cubicweb.server.session import hooks_control

for uri, cfg in config.read_sources_file().items():
    if uri in ('system', 'admin'):
        continue
    repo.sources_by_uri[uri] = repo.get_source(cfg['adapter'], uri, cfg.copy())

add_entity_type('CWSource')
add_relation_definition('CWSource', 'cw_source', 'CWSource')
add_entity_type('CWSourceHostConfig')

with hooks_control(session, session.HOOKS_ALLOW_ALL, 'cw.sources'):
    create_entity('CWSource', type=u'native', name=u'system')
commit()

sql('INSERT INTO cw_source_relation(eid_from,eid_to) '
    'SELECT e.eid,s.cw_eid FROM entities as e, cw_CWSource as s '
    'WHERE s.cw_name=e.type')
commit()

for uri, cfg in config.read_sources_file().items():
    if uri in ('system', 'admin'):
        continue
    repo.sources_by_uri.pop(uri)
    config = u'\n'.join('%s=%s' % (key, value) for key, value in cfg.items()
                        if key != 'adapter' and value is not None)
    create_entity('CWSource', name=text_type(uri), type=text_type(cfg['adapter']),
                  config=config)
commit()

# rename cwprops for boxes/contentnavigation
for x in rql('Any X,XK WHERE X pkey XK, '
             'X pkey ~= "boxes.%" OR '
             'X pkey ~= "contentnavigation.%"').entities():
    x.cw_set(pkey=u'ctxcomponents.' + x.pkey.split('.', 1)[1])