[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.
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()