[Zope-Checkins] CVS: Zope/lib/python/AccessControl - Implementation.py:1.3 cAccessControl.c:1.26

Brian Lloyd brian at zope.com
Fri Jan 16 13:49:53 EST 2004


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

Modified Files:
	Implementation.py cAccessControl.c 
Log Message:
reenable cAccessControl


=== Zope/lib/python/AccessControl/Implementation.py 1.2 => 1.3 ===
--- Zope/lib/python/AccessControl/Implementation.py:1.2	Thu Jan 15 18:09:03 2004
+++ Zope/lib/python/AccessControl/Implementation.py	Fri Jan 16 13:49:22 2004
@@ -34,28 +34,20 @@
     """Select the policy implementation to use.
 
     'name' must be either 'PYTHON' or 'C'.
-
-    XXX:  'C' version is currently broken
     """
     import sys
     global _implementation_name
-    #
+
     name = name.upper()
     if name == _implementation_name:
         return
     if name == "C":
-        raise NotImplementedError( # XXX
-                "'C' version of ZSP not yet working.")
-        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)
@@ -91,5 +83,4 @@
 
 
 # start with the default, mostly because we need something for the tests
-#setImplementation("C")   XXX: C version of ZSP isn't yet working
-setImplementation("PYTHON")
+setImplementation("C")


=== Zope/lib/python/AccessControl/cAccessControl.c 1.25 => 1.26 ===
--- Zope/lib/python/AccessControl/cAccessControl.c:1.25	Wed Jan 14 14:42:30 2004
+++ Zope/lib/python/AccessControl/cAccessControl.c	Fri Jan 16 13:49:22 2004
@@ -674,6 +674,7 @@
 static PyObject *aq_validate = NULL;
 static PyObject *aq_parent_str = NULL;
 static PyObject *_check_context_str = NULL;
+static PyObject *getRoles = NULL;
 
 static int ownerous = 1;
 static int authenticated = 1;
@@ -785,8 +786,8 @@
           return NULL;
 
 	/*| # Provide special rules for acquisition attributes
-	**| if type(name) in (StringType, UnicodeType):
-	**|     if name[:3] == 'aq_' and name not in valid_aq_:
+	**| if isinstance(name, str):
+	**|     if name.startswith('aq_') and name not in valid_aq_:
 	**|	   raise Unauthorized(name, value)
 	*/ 
 
@@ -807,6 +808,30 @@
 
 	Py_XINCREF(roles);	/* Convert the borrowed ref to a real one */
 
+	/* new */
+
+	/*| # If roles weren't passed in, we'll try to get them from
+	**| # the object
+	**|
+	**| if roles is _noroles:
+	**|    roles = getRoles(container, name, value, _noroles)
+	*/
+
+        if (roles == NULL) {
+	  /* Note that the '_noroles' arg is just a marker - our C version
+             of _noroles is null */
+	  roles = callfunction4(getRoles, container, name, value, getRoles);
+	  if (roles == getRoles) {
+	    Py_DECREF(roles);
+            roles = NULL;
+	  }
+          if (roles == NULL)
+            PyErr_Clear();
+	}
+
+
+	/* old */
+
 	/*| # If roles weren't passed in, we'll try to get them from
 	**| # the object
 	**|
@@ -820,6 +845,10 @@
             PyErr_Clear();
 	}
 
+
+
+
+
 	/*| # We still might not have any roles
 	**| 
 	**| if roles is _noroles:
@@ -2361,6 +2390,16 @@
 	GETATTR(module, ContainerAssertions);
 	Py_DECREF(module);
 	module = NULL;
+
+
+	/*| from ZopeSecurityPolicy import getRoles
+	*/
+
+	IMPORT(module, "AccessControl.ZopeSecurityPolicy");
+	GETATTR(module, getRoles);
+	Py_DECREF(module);
+	module = NULL;
+
 
 	/*| from unauthorized import Unauthorized
 	*/




More information about the Zope-Checkins mailing list