[z3-checkins] r9793 - z3/Five/trunk

efge at codespeak.net efge at codespeak.net
Tue Mar 15 15:38:50 MET 2005


Author: efge
Date: Tue Mar 15 15:38:50 2005
New Revision: 9793

Modified:
   z3/Five/trunk/zcml.py
Log:
Merge 9790:9791 from branch:
Cleanup and make sure things are really initialized only once.



Modified: z3/Five/trunk/zcml.py
==============================================================================
--- z3/Five/trunk/zcml.py	(original)
+++ z3/Five/trunk/zcml.py	Tue Mar 15 15:38:50 2005
@@ -10,53 +10,27 @@
 
 $Id$
 """
+import os
 from zope.configuration import xmlconfig
-import Products
 
 _initialized = False
-_global_context = None
-def initialize(execute=True):
-    """This gets called once to initialize ZCML enough.
-    """
-    global _initialized, _global_context
-    if _initialized:
-        return _global_context
-    _initialized = True
-    return _global_context
-
-def reset():
-    global _initialized, _global_context
-    _initialized = False
-    _global_context = None
 
-def process(file, execute=True, package=None):
-    """Process a ZCML file.
-
-    Note that this can be called multiple times, unlike in Zope 3. This
-    is needed because in Zope 2 we don't (yet) have a master ZCML file
-    which can include all the others.
-    """
-    context = initialize()
-    return xmlconfig.file(file, context=context, execute=execute,
-                          package=package)
-
-def string(s, execute=True):
-    """Process a ZCML string.
+def load_site():
+    """Load the appropriate ZCML file.
 
     Note that this can be called multiple times, unlike in Zope 3. This
     is needed because in Zope 2 we don't (yet) have a master ZCML file
     which can include all the others.
     """
-    context = initialize()
-    return xmlconfig.string(s, context=context, execute=execute)
-
-import os
+    global _initialized
+    if _initialized:
+        return
+    _initialized = True
 
-def load_site():
     # load instance site configuration file
     site_zcml = os.path.join(INSTANCE_HOME, "etc", "site.zcml")
     if os.path.exists(site_zcml):
-        process(site_zcml)
+        file = site_zcml
     else:
-        fallback = os.path.join(os.path.dirname(__file__), "skel", "site.zcml")
-        process(fallback)
+        file = os.path.join(os.path.dirname(__file__), "skel", "site.zcml")
+    xmlconfig.file(file)


More information about the z3-checkins mailing list