[Zope-Checkins] CVS: Zope/lib/python/AccessControl - Implementation.py:1.1.2.5

Brian Lloyd brian at zope.com
Thu Jan 29 14:23:00 EST 2004


Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv29556/lib/python/AccessControl

Modified Files:
      Tag: Zope-2_7-branch
	Implementation.py 
Log Message:
fix & document setImplementation semantics


=== Zope/lib/python/AccessControl/Implementation.py 1.1.2.4 => 1.1.2.5 ===
--- Zope/lib/python/AccessControl/Implementation.py:1.1.2.4	Mon Jan 19 09:50:52 2004
+++ Zope/lib/python/AccessControl/Implementation.py	Thu Jan 29 14:22:29 2004
@@ -31,27 +31,29 @@
 
 
 def setImplementation(name):
-    """Select the policy implementation to use.
-
-    'name' must be either 'PYTHON' or 'C'.
+    """Select the policy implementation to use. The 'name' must be either
+       'PYTHON' or 'C'. NOTE: this function is intended to be called
+       exactly once, so that the Zope config file can dictate the policy
+       implementation to be used. Subsequent calls to this function will
+       have no effect!!
     """
     import sys
     global _implementation_name
-    #
+    global _implementation_set
+
+    if _implementation_set:
+        return
+
     name = name.upper()
     if name == _implementation_name:
         return
     if name == "C":
-        try:
-            from AccessControl import ImplC as impl
-        except ImportError:
-            name = "PYTHON"
-            from AccessControl import ImplPython as impl
+        from AccessControl import ImplC as impl
     elif name == "PYTHON":
         from AccessControl import ImplPython as impl
     else:
         raise ValueError("unknown policy implementation: %r" % name)
-    #
+
     _implementation_name = name
     for modname, names in _policy_names.items():
         __import__(modname)
@@ -61,8 +63,10 @@
         if hasattr(mod, "initialize"):
             mod.initialize(impl)
 
+    _implementation_set = 1
 
 _implementation_name = None
+_implementation_set = 0
 
 _policy_names = {
     "AccessControl": ("setDefaultBehaviors",




More information about the Zope-Checkins mailing list