misc/migration/3.15.4_Any.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Jan 2013 18:01:25 +0100
changeset 8669 62213a34726e
parent 8522 85b1c4b36d1d
child 10589 7c23b7de2b8d
permissions -rw-r--r--
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848 eg no more specific option of pyro ns host, group, etc. This also fixes broken ZMQ sources. Changes: * dropped pyro-ns-host, pyro-instance-id, pyro-ns-group from client side config, in favor of repository-uri. No migration done, supposing there is **no web-only config** in the wild. Also stop discovering the connection method through the repo_method class attribute of the configuration, varying according to the configuration class. This is a first step on the way to a simpler configuration handling. Notice those pyro options are still available for repository only / all-in-one configurations as they are needed to configure the pyro server. * stop telling connection method using ConnectionProperties, this is so boring. Also, drop _cnxtype from Connection and cnxtype from Session. The former is replaced by a is_repo_in_memory property and the later is totaly useless. * deprecate in_memory_cnx which becomes useless, use _repo_connect instead
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8522
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
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
     2
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
     3
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
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
     5
    salt = user.upassword.getvalue()
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
    if crypt_password('', salt) == salt:
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
        passwd = generate_password()
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
        print 'setting random password for user %s' % user.login
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
        user.set_attributes(upassword=passwd)
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
commit()