cubicweb/misc/migration/3.15.0_Any.py
author Philippe Pepiot <ph@itsalwaysdns.eu>
Mon, 30 Mar 2020 15:17:10 +0200
changeset 12958 3667f6df1ec3
parent 12567 26744ad37953
permissions -rw-r--r--
[server] extract "no pooler" CnxSet class to a _BaseCnxSet class So we get rid of "if self._queue is None" in each method of _CnxSetPool Also add helper get_cnxset(source, size) to instantiate the correct pooler class.

from cubicweb.server import SOURCE_TYPES
from cubicweb.server.serverconfig import (SourceConfiguration,
                                          generate_source_config)


sync_schema_props_perms('EmailAddress')


def update_config(source, **config):
    cfg = source.dictconfig
    cfg.update(config)
    options = SOURCE_TYPES[source.type].options
    sconfig = SourceConfiguration(source._cw.vreg.config, options=options)
    for opt, val in cfg.items():
        try:
            sconfig.set_option(opt, val)
        except OptionError:
            continue
    cfgstr = str(generate_source_config(sconfig), source._cw.encoding)
    source.cw_set(config=cfgstr)


for source in rql('CWSource X WHERE X type "ldapuser"').entities():
    config = source.dictconfig
    host = config.pop('host', u'ldap')
    protocol = config.pop('protocol', u'ldap')
    source.cw_set(url=u'%s://%s' % (protocol, host))
    update_config(source, **config)

commit()