introduce init_registration method and call it in repo initialization tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 09 Apr 2009 13:51:01 +0200
branchtls-sprint
changeset 1316 6d71d38822ee
parent 1315 86bddd181e03
child 1317 12dc957a5b55
introduce init_registration method and call it in repo initialization
server/repository.py
vregistry.py
--- a/server/repository.py	Thu Apr 09 12:55:00 2009 +0200
+++ b/server/repository.py	Thu Apr 09 13:51:01 2009 +0200
@@ -181,8 +181,11 @@
             # need to load the Any and EUser entity types
             self.vreg.schema = self.schema
             etdirectory = join(CW_SOFTWARE_ROOT, 'entities')
-            self.vreg.load_file(etdirectory, '__init__.py')
-            self.vreg.load_file(etdirectory, 'authobjs.py')
+            self.init_registration(etdirectory)
+            self.vreg.load_file(join(etdirectory, '__init__.py'),
+                                'cubicweb.entities.__init__')
+            self.vreg.load_file(join(etdirectory, 'authobjs.py'),
+                                'cubicweb.entities.authobjs')
         else:
             # test start: use the file system schema (quicker)
             self.warning("set fs application'schema")
--- a/vregistry.py	Thu Apr 09 12:55:00 2009 +0200
+++ b/vregistry.py	Thu Apr 09 13:51:01 2009 +0200
@@ -351,6 +351,12 @@
     
     # intialization methods ###################################################
     
+    def init_registration(self, path):
+        # compute list of all modules that have to be loaded
+        self._toloadmods, filemods = _toload_info(path)
+        self._loadedmods = {}
+        return filemods
+    
     def register_objects(self, path, force_reload=None):
         if force_reload is None:
             force_reload = self.config.mode == 'dev'
@@ -370,16 +376,14 @@
                 sys.path.remove(webdir)
         if CW_SOFTWARE_ROOT in sys.path:
             sys.path.remove(CW_SOFTWARE_ROOT)
-        # compute list of all modules that have to be loaded
-        self._toloadmods, filemods = _toload_info(path)
-        self._loadedmods = {}
         # load views from each directory in the application's path
+        filemods = self.init_registration(path)
         change = False
         for filepath, modname in filemods:
             if self.load_file(filepath, modname, force_reload):
                 change = True
         return change
-
+    
     def load_file(self, filepath, modname, force_reload=False):
         """load visual objects from a python file"""
         from logilab.common.modutils import load_module_from_name