server/__init__.py
branchstable
changeset 7056 51f88f13d6f3
parent 6427 c8a5ac2d1eaa
child 7061 bb2080547722
child 7079 6024de6094f6
equal deleted inserted replaced
7055:a393ebb880cd 7056:51f88f13d6f3
   119 def init_repository(config, interactive=True, drop=False, vreg=None):
   119 def init_repository(config, interactive=True, drop=False, vreg=None):
   120     """initialise a repository database by creating tables add filling them
   120     """initialise a repository database by creating tables add filling them
   121     with the minimal set of entities (ie at least the schema, base groups and
   121     with the minimal set of entities (ie at least the schema, base groups and
   122     a initial user)
   122     a initial user)
   123     """
   123     """
   124     from cubicweb.dbapi import in_memory_cnx
   124     from cubicweb.dbapi import in_memory_repo_cnx
   125     from cubicweb.server.repository import Repository
   125     from cubicweb.server.repository import Repository
   126     from cubicweb.server.utils import manager_userpasswd
   126     from cubicweb.server.utils import manager_userpasswd
   127     from cubicweb.server.sqlutils import sqlexec, sqlschema, sqldropschema
   127     from cubicweb.server.sqlutils import sqlexec, sqlschema, sqldropschema
   128     # configuration to avoid db schema loading and user'state checking
   128     # configuration to avoid db schema loading and user'state checking
   129     # on connection
   129     # on connection
   183                     {'u': admin.eid})
   183                     {'u': admin.eid})
   184     session.commit()
   184     session.commit()
   185     repo.shutdown()
   185     repo.shutdown()
   186     # reloging using the admin user
   186     # reloging using the admin user
   187     config._cubes = None # avoid assertion error
   187     config._cubes = None # avoid assertion error
   188     repo, cnx = in_memory_cnx(config, login, password=pwd)
   188     repo, cnx = in_memory_repo_cnx(config, login, password=pwd)
   189     repo.system_source.eid = ssource.eid # redo this manually
   189     repo.system_source.eid = ssource.eid # redo this manually
   190     # trigger vreg initialisation of entity classes
   190     # trigger vreg initialisation of entity classes
   191     config.cubicweb_appobject_path = set(('entities',))
   191     config.cubicweb_appobject_path = set(('entities',))
   192     config.cube_appobject_path = set(('entities',))
   192     config.cube_appobject_path = set(('entities',))
   193     repo.vreg.set_schema(repo.schema)
   193     repo.vreg.set_schema(repo.schema)