cubicweb/misc/migration/3.15.4_Any.py
author Laurent Wouters <lwouters@cenotelie.fr>
Fri, 20 Mar 2020 14:34:07 +0100
changeset 12931 6eae252361e5
parent 11057 0b59724cb3f2
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:
10589
7c23b7de2b8d [py3k] print function
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents: 8522
diff changeset
     1
from __future__ import print_function
7c23b7de2b8d [py3k] print function
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents: 8522
diff changeset
     2
8522
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
from logilab.common.shellutils import generate_password
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
from cubicweb.server.utils import crypt_password
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities():
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
    salt = user.upassword.getvalue()
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
    if crypt_password('', salt) == salt:
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
        passwd = generate_password()
10589
7c23b7de2b8d [py3k] print function
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents: 8522
diff changeset
    10
        print('setting random password for user %s' % user.login)
8522
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
        user.set_attributes(upassword=passwd)
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    12
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    13
commit()