[Checkins] SVN: Zope/trunk/src/ Prevent ZopeTestCase to load any ZCML as a side-effect of calling Zope2.app(). Loading ZCML has to be deferred to layer setup time.

Hanno Schlichting hannosch at hannosch.eu
Mon Aug 2 12:57:49 EDT 2010


Log message for revision 115379:
  Prevent ZopeTestCase to load any ZCML as a side-effect of calling Zope2.app(). Loading ZCML has to be deferred to layer setup time.
  

Changed:
  U   Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py
  U   Zope/trunk/src/Zope2/App/startup.py

-=-
Modified: Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py	2010-08-02 14:45:12 UTC (rev 115378)
+++ Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py	2010-08-02 16:57:49 UTC (rev 115379)
@@ -129,6 +129,11 @@
     def null_register_help(self,directory='',clear=1,title_re=None): pass
     App.ProductContext.ProductContext.registerHelp = null_register_help
 
+    # Avoid loading any ZCML
+    from Zope2.App import startup as zopeapp_startup
+    def null_load_zcml(): pass
+    zopeapp_startup.load_zcml = null_load_zcml
+
     # Note that we applied the monkey patches
     global _patched
     _patched = True

Modified: Zope/trunk/src/Zope2/App/startup.py
===================================================================
--- Zope/trunk/src/Zope2/App/startup.py	2010-08-02 14:45:12 UTC (rev 115378)
+++ Zope/trunk/src/Zope2/App/startup.py	2010-08-02 16:57:49 UTC (rev 115379)
@@ -46,6 +46,16 @@
 startup_time = asctime()
 
 
+def load_zcml():
+    # This hook is overriden by ZopeTestCase
+    from .zcml import load_site
+    load_site()
+
+    # Set up Zope2 specific vocabulary registry
+    from .schema import configure_vocabulary_registry
+    configure_vocabulary_registry()
+
+
 def startup():
     from App.PersistentExtra import patchPersistent
     import Globals  # to set / fetch data
@@ -105,13 +115,8 @@
     newSecurityManager(None, AccessControl.User.system)
 
     # Set up the CA
-    from .zcml import load_site
-    load_site()
+    load_zcml()
 
-    # Set up Zope2 specific vocabulary registry
-    from .schema import configure_vocabulary_registry
-    configure_vocabulary_registry()
-
     # Set up the "app" object that automagically opens
     # connections
     app = App.ZApplication.ZApplicationWrapper(



More information about the checkins mailing list