Commit 26791c09 authored by Brian Lloyd's avatar Brian Lloyd

reenable cAccessControl

parent f54fc698
......@@ -34,28 +34,20 @@ def setImplementation(name):
"""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
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 @@ _policy_names = {
# 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")
......@@ -36,7 +36,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
$Id: cAccessControl.c,v 1.25 2004/01/14 19:42:30 Brian Exp $
$Id: cAccessControl.c,v 1.26 2004/01/16 18:49:22 Brian Exp $
If you have questions regarding this software,
contact:
......@@ -674,6 +674,7 @@ static PyObject *unrestrictedTraverse_str = NULL;
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 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
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 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
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 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
PyErr_Clear();
}
/*| # We still might not have any roles
**|
**| if roles is _noroles:
......@@ -2323,7 +2352,7 @@ void initcAccessControl(void) {
module = Py_InitModule3("cAccessControl",
cAccessControl_methods,
"$Id: cAccessControl.c,v 1.25 2004/01/14 19:42:30 Brian Exp $\n");
"$Id: cAccessControl.c,v 1.26 2004/01/16 18:49:22 Brian Exp $\n");
aq_init(); /* For Python <= 2.1.1, aq_init() should be after
Py_InitModule(). */
......@@ -2362,6 +2391,16 @@ void initcAccessControl(void) {
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
*/
......
......@@ -38,11 +38,6 @@ class AccessControlImplementationTest(unittest.TestCase):
setImplementation(self.original)
def test_setImplemenationC(self):
# XXX: 'C' ZSP is not yet working
self.assertRaises( NotImplementedError, setImplementation, "C")
return
setImplementation("C")
name = getImplementationName()
if self.have_cAccessControl:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment