cubicweb/misc/migration/3.15.0_Any.py
author Laurent Wouters <lwouters@cenotelie.fr>
Fri, 20 Mar 2020 14:34:07 +0100
changeset 12931 6eae252361e5
parent 12567 26744ad37953
permissions -rw-r--r--
[rql] Store selected variables for RQL select queries in ResultSet (#17218476) By storing the name of the selected variables for RQL select queries in the ResultSet (within the "variables" attribute), the information can be passed down to specific protocols, e.g. rqlio that may wish to pass is down further to clients. In turn, clients can then choose to present the results of RQL select queries as symbolic bindings using the names used in the query's projection, instead of ordinal arrays.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12133
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     1
from cubicweb.server import SOURCE_TYPES
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     2
from cubicweb.server.serverconfig import (SourceConfiguration,
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     3
                                          generate_source_config)
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     4
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     5
8158
2ee254e74382 [schema] restrictive email address read permission. Closes #2148141
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
sync_schema_props_perms('EmailAddress')
8188
1867e252e487 [repository] ldap-feed source. Closes #2086984
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8158
diff changeset
     7
12133
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     8
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
     9
def update_config(source, **config):
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    10
    cfg = source.dictconfig
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    11
    cfg.update(config)
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    12
    options = SOURCE_TYPES[source.type].options
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    13
    sconfig = SourceConfiguration(source._cw.vreg.config, options=options)
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    14
    for opt, val in cfg.items():
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    15
        try:
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    16
            sconfig.set_option(opt, val)
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    17
        except OptionError:
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    18
            continue
12567
26744ad37953 Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12133
diff changeset
    19
    cfgstr = str(generate_source_config(sconfig), source._cw.encoding)
12133
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    20
    source.cw_set(config=cfgstr)
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    21
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    22
8188
1867e252e487 [repository] ldap-feed source. Closes #2086984
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8158
diff changeset
    23
for source in rql('CWSource X WHERE X type "ldapuser"').entities():
1867e252e487 [repository] ldap-feed source. Closes #2086984
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8158
diff changeset
    24
    config = source.dictconfig
8251
df46bf02b107 [ldap migration] use unicode strings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8188
diff changeset
    25
    host = config.pop('host', u'ldap')
df46bf02b107 [ldap migration] use unicode strings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8188
diff changeset
    26
    protocol = config.pop('protocol', u'ldap')
8483
4ba11607d84a [entity api] unify set_attributes / set_relations into a cw_set method. Closes #2423719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8251
diff changeset
    27
    source.cw_set(url=u'%s://%s' % (protocol, host))
12133
8743c3bda480 [entities] Move CWSource update_config method as a function in 3.15 migration script
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    28
    update_config(source, **config)
8188
1867e252e487 [repository] ldap-feed source. Closes #2086984
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8158
diff changeset
    29
1867e252e487 [repository] ldap-feed source. Closes #2086984
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8158
diff changeset
    30
commit()