fix create_user function introduced in d6ae30c5d055 for database initialization: messup admin user groups when anon is created due to missing restriction stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 18 Feb 2010 13:30:37 +0100
branchstable
changeset 4634 b2a3232783f8
parent 4633 a85b4361fb22
child 4635 44a883148ab4
fix create_user function introduced in d6ae30c5d055 for database initialization: messup admin user groups when anon is created due to missing restriction
server/__init__.py
--- a/server/__init__.py	Thu Feb 18 13:28:38 2010 +0100
+++ b/server/__init__.py	Thu Feb 18 13:30:37 2010 +0100
@@ -96,10 +96,11 @@
 def create_user(session, login, pwd, *groups):
     # monkey patch this method if you want to customize admin/anon creation
     # (that maybe necessary if you change CWUser's schema)
-    session.create_entity('CWUser', login=login, upassword=pwd)
+    user = session.create_entity('CWUser', login=login, upassword=pwd)
     for group in groups:
-        session.execute('SET U in_group G WHERE G name %(group)s',
-                        {'group': group})
+        session.execute('SET U in_group G WHERE U eid %(u)s, G name %(group)s',
+                        {'u': user.eid, 'group': group})
+    return user
 
 def init_repository(config, interactive=True, drop=False, vreg=None):
     """initialise a repository database by creating tables add filling them