[repo initialisation] during repo creation, load all hooks and entities code
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 10 Sep 2012 14:02:06 +0200
changeset 8539 d32ab8570e5d
parent 8538 00597256de18
child 8540 fee98af8bb33
[repo initialisation] during repo creation, load all hooks and entities code this simplify code and make it more consistent
server/__init__.py
server/repository.py
--- a/server/__init__.py	Mon Sep 10 13:53:59 2012 +0200
+++ b/server/__init__.py	Mon Sep 10 14:02:06 2012 +0200
@@ -224,10 +224,6 @@
     config._cubes = None # avoid assertion error
     repo, cnx = in_memory_repo_cnx(config, login, password=pwd)
     repo.system_source.eid = ssource.eid # redo this manually
-    # trigger vreg initialisation of entity classes
-    config.cubicweb_appobject_path = set(('entities',))
-    config.cube_appobject_path = set(('entities',))
-    repo.vreg.set_schema(repo.schema)
     assert len(repo.sources) == 1, repo.sources
     handler = config.migration_handler(schema, interactive=False,
                                        cnx=cnx, repo=repo)
--- a/server/repository.py	Mon Sep 10 13:53:59 2012 +0200
+++ b/server/repository.py	Mon Sep 10 14:02:06 2012 +0200
@@ -207,16 +207,10 @@
         elif config.creating:
             # repository creation
             config.bootstrap_cubes()
-            self.set_schema(config.load_schema(), resetvreg=False)
-            # need to load the Any and CWUser entity types
-            etdirectory = join(CW_SOFTWARE_ROOT, 'entities')
-            self.vreg.init_registration([etdirectory])
-            for modname in ('__init__', 'authobjs', 'wfobjs'):
-                self.vreg.load_file(join(etdirectory, '%s.py' % modname),
-                                    'cubicweb.entities.%s' % modname)
-            hooksdirectory = join(CW_SOFTWARE_ROOT, 'hooks')
-            self.vreg.load_file(join(hooksdirectory, 'metadata.py'),
-                                'cubicweb.hooks.metadata')
+            # trigger vreg initialisation of entity classes
+            config.cubicweb_appobject_path = set(('hooks', 'entities'))
+            config.cube_appobject_path = set(('hooks', 'entities'))
+            self.set_schema(config.load_schema())
         elif config.read_instance_schema:
             # normal start: load the instance schema from the database
             self.fill_schema()