[py3k] unicode → six.text_type
authorRémi Cardona <remi.cardona@logilab.fr>
Tue, 15 Sep 2015 17:32:30 +0200
changeset 10679 76bb963c7e8e
parent 10678 77333ec71fab
child 10680 1b4df4b3cd9a
[py3k] unicode → six.text_type
server/__init__.py
--- a/server/__init__.py	Tue Sep 15 17:31:07 2015 +0200
+++ b/server/__init__.py	Tue Sep 15 17:32:30 2015 +0200
@@ -29,7 +29,7 @@
 from glob import glob
 from contextlib import contextmanager
 
-from six import string_types
+from six import text_type, string_types
 
 from logilab.common.modutils import LazyObject
 from logilab.common.textutils import splitstrip
@@ -199,7 +199,7 @@
     user = session.create_entity('CWUser', login=login, upassword=pwd)
     for group in groups:
         session.execute('SET U in_group G WHERE U eid %(u)s, G name %(group)s',
-                        {'u': user.eid, 'group': unicode(group)})
+                        {'u': user.eid, 'group': text_type(group)})
     return user
 
 def init_repository(config, interactive=True, drop=False, vreg=None,
@@ -272,17 +272,17 @@
         # insert base groups and default admin
         print('-> inserting default user and default groups.')
         try:
-            login = unicode(sourcescfg['admin']['login'])
+            login = text_type(sourcescfg['admin']['login'])
             pwd = sourcescfg['admin']['password']
         except KeyError:
             if interactive:
                 msg = 'enter login and password of the initial manager account'
                 login, pwd = manager_userpasswd(msg=msg, confirm=True)
             else:
-                login, pwd = unicode(source['db-user']), source['db-password']
+                login, pwd = text_type(source['db-user']), source['db-password']
         # sort for eid predicatability as expected in some server tests
         for group in sorted(BASE_GROUPS):
-            cnx.create_entity('CWGroup', name=unicode(group))
+            cnx.create_entity('CWGroup', name=text_type(group))
         admin = create_user(cnx, login, pwd, u'managers')
         cnx.execute('SET X owned_by U WHERE X is IN (CWGroup,CWSource), U eid %(u)s',
                         {'u': admin.eid})