fix duplicated vregistry initialization during tests stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Sat, 06 Feb 2010 10:31:27 +0100
branchstable
changeset 4484 d87989d91635
parent 4457 297a63704761
child 4485 5f99eb0b99f7
fix duplicated vregistry initialization during tests
web/application.py
--- a/web/application.py	Thu Feb 04 18:29:43 2010 +0100
+++ b/web/application.py	Sat Feb 06 10:31:27 2010 +0100
@@ -226,17 +226,23 @@
     def __init__(self, config, debug=None,
                  session_handler_fact=CookieSessionHandler,
                  vreg=None):
-        super(CubicWebPublisher, self).__init__()
-        # connect to the repository and get instance's schema
+        self.info('starting web instance from %s', config.apphome)
         if vreg is None:
             vreg = cwvreg.CubicWebVRegistry(config, debug=debug)
+            need_set_schema = True
+        else:
+            # vreg is specified during test and the vreg is already properly
+            # initialized. Even, reinitializing it may cause some unwanted
+            # side effect due to unproper reloading of appobjects modules
+            need_set_schema = False
         self.vreg = vreg
-        self.info('starting web instance from %s', config.apphome)
+        # connect to the repository and get instance's schema
         self.repo = config.repository(vreg)
         if not vreg.initialized:
             self.config.init_cubes(self.repo.get_cubes())
             vreg.init_properties(self.repo.properties())
-        vreg.set_schema(self.repo.get_schema())
+        if need_set_schema:
+            vreg.set_schema(self.repo.get_schema())
         # set the correct publish method
         if config['query-log-file']:
             from threading import Lock