94 # database initialization ###################################################### |
94 # database initialization ###################################################### |
95 |
95 |
96 def create_user(session, login, pwd, *groups): |
96 def create_user(session, login, pwd, *groups): |
97 # monkey patch this method if you want to customize admin/anon creation |
97 # monkey patch this method if you want to customize admin/anon creation |
98 # (that maybe necessary if you change CWUser's schema) |
98 # (that maybe necessary if you change CWUser's schema) |
99 session.create_entity('CWUser', login=login, upassword=pwd) |
99 user = session.create_entity('CWUser', login=login, upassword=pwd) |
100 for group in groups: |
100 for group in groups: |
101 session.execute('SET U in_group G WHERE G name %(group)s', |
101 session.execute('SET U in_group G WHERE U eid %(u)s, G name %(group)s', |
102 {'group': group}) |
102 {'u': user.eid, 'group': group}) |
|
103 return user |
103 |
104 |
104 def init_repository(config, interactive=True, drop=False, vreg=None): |
105 def init_repository(config, interactive=True, drop=False, vreg=None): |
105 """initialise a repository database by creating tables add filling them |
106 """initialise a repository database by creating tables add filling them |
106 with the minimal set of entities (ie at least the schema, base groups and |
107 with the minimal set of entities (ie at least the schema, base groups and |
107 a initial user) |
108 a initial user) |