Commit b9c22bfa authored by matt@zope.com's avatar matt@zope.com

Add extra test needed in imPermissionRole_of (indenting problem)

parent 08ce94e3
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
$Id: cAccessControl.c,v 1.5 2001/06/29 18:10:18 matt Exp $ $Id: cAccessControl.c,v 1.6 2001/06/29 22:18:48 matt Exp $
If you have questions regarding this software, If you have questions regarding this software,
contact: contact:
...@@ -72,14 +72,14 @@ typedef struct { ...@@ -72,14 +72,14 @@ typedef struct {
PyObject_HEAD PyObject_HEAD
PyObject *__name__; PyObject *__name__;
PyObject *_p; PyObject *_p;
PyObject *_d; PyObject *__roles__;
} PermissionRole; } PermissionRole;
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
PyObject *_p; PyObject *_p;
PyObject *_pa; PyObject *_pa;
PyObject *_d; PyObject *__roles__;
PyObject *_v; PyObject *_v;
} imPermissionRole; } imPermissionRole;
...@@ -418,6 +418,7 @@ static void unauthErr(PyObject *name, PyObject *value) { ...@@ -418,6 +418,7 @@ static void unauthErr(PyObject *name, PyObject *value) {
Py_DECREF(_name); Py_DECREF(_name);
_name = PyObject_GetAttrString(value,"id"); _name = PyObject_GetAttrString(value,"id");
if (_name == NULL) { if (_name == NULL) {
PyErr_Clear();
_name = PyObject_GetAttrString(value,"__name__"); _name = PyObject_GetAttrString(value,"__name__");
} }
...@@ -523,6 +524,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) { ...@@ -523,6 +524,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
Py_XDECREF(roles); Py_XDECREF(roles);
roles = PyObject_GetAttrString(value, "__roles__"); roles = PyObject_GetAttrString(value, "__roles__");
if (roles == NULL) { if (roles == NULL) {
PyErr_Clear();
Py_INCREF(_noroles); Py_INCREF(_noroles);
roles = _noroles; roles = _noroles;
} }
...@@ -566,6 +568,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) { ...@@ -566,6 +568,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
roles = PyObject_GetAttrString(container, "__roles__"); roles = PyObject_GetAttrString(container, "__roles__");
if (roles == NULL) { if (roles == NULL) {
PyErr_Clear();
Py_INCREF(_noroles); Py_INCREF(_noroles);
roles = _noroles; roles = _noroles;
} }
...@@ -575,6 +578,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) { ...@@ -575,6 +578,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
aq = PyObject_GetAttrString(container, "aq_acquire"); aq = PyObject_GetAttrString(container, "aq_acquire");
if (aq == NULL) { if (aq == NULL) {
PyErr_Clear();
Py_DECREF(roles); Py_DECREF(roles);
if (containerbase != accessedbase) { if (containerbase != accessedbase) {
rval = PyInt_FromLong(0); rval = PyInt_FromLong(0);
...@@ -625,6 +629,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) { ...@@ -625,6 +629,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
p = PyObject_GetAttrString(container, p = PyObject_GetAttrString(container,
"__allow_access_to_unprotected_subobjects__"); "__allow_access_to_unprotected_subobjects__");
if (p == NULL) { if (p == NULL) {
PyErr_Clear();
Py_INCREF(Py_None); Py_INCREF(Py_None);
p = Py_None; p = Py_None;
} }
...@@ -821,6 +826,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) { ...@@ -821,6 +826,7 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
*/ */
proxy_roles = PyObject_GetAttrString(eo, "_proxy_roles"); proxy_roles = PyObject_GetAttrString(eo, "_proxy_roles");
if (proxy_roles == NULL) { if (proxy_roles == NULL) {
PyErr_Clear();
Py_INCREF(Py_None); Py_INCREF(Py_None);
proxy_roles = Py_None; proxy_roles = Py_None;
} }
...@@ -890,6 +896,8 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) { ...@@ -890,6 +896,8 @@ static PyObject *ZopeSecurityPolicy_validate(PyObject *self, PyObject *args) {
Py_DECREF(allowed); Py_DECREF(allowed);
} }
Py_DECREF(user); Py_DECREF(user);
} else {
PyErr_Clear();
} }
/*| # we don't want someone to acquire if they can't get an /*| # we don't want someone to acquire if they can't get an
...@@ -995,7 +1003,7 @@ static PyObject *PermissionRole_getattr(PermissionRole *self, char *name) { ...@@ -995,7 +1003,7 @@ static PyObject *PermissionRole_getattr(PermissionRole *self, char *name) {
#define IZZIT(n) if (strcmp(#n, name) == 0) { Py_INCREF(self->n); return self->n; } #define IZZIT(n) if (strcmp(#n, name) == 0) { Py_INCREF(self->n); return self->n; }
IZZIT(__name__); IZZIT(__name__);
IZZIT(_p); IZZIT(_p);
IZZIT(_d); IZZIT(__roles__);
return Py_FindAttrString(OBJECT(self), name); return Py_FindAttrString(OBJECT(self), name);
} }
...@@ -1013,7 +1021,7 @@ static int PermissionRole_setattr(PermissionRole *self, char *name, ...@@ -1013,7 +1021,7 @@ static int PermissionRole_setattr(PermissionRole *self, char *name,
IZZITA(__name__); IZZITA(__name__);
IZZITA(_p); IZZITA(_p);
IZZITA(_d); IZZITA(__roles__);
sname = PyString_FromString(name); sname = PyString_FromString(name);
...@@ -1047,7 +1055,7 @@ static PyObject *PermissionRole_init(PermissionRole *self, PyObject *args) { ...@@ -1047,7 +1055,7 @@ static PyObject *PermissionRole_init(PermissionRole *self, PyObject *args) {
self->_p = permissionName(name); self->_p = permissionName(name);
self->_d = deflt; self->__roles__ = deflt;
Py_INCREF(deflt); Py_INCREF(deflt);
Py_INCREF(Py_None); Py_INCREF(Py_None);
...@@ -1092,8 +1100,8 @@ static PyObject *PermissionRole_of(PermissionRole *self, PyObject *args) { ...@@ -1092,8 +1100,8 @@ static PyObject *PermissionRole_of(PermissionRole *self, PyObject *args) {
/*| r._d = self._d /*| r._d = self._d
*/ */
r->_d = self->_d; r->__roles__ = self->__roles__;
Py_INCREF(r->_d); Py_INCREF(r->__roles__);
/*| p = getattr(parent, 'aq_inner', None) /*| p = getattr(parent, 'aq_inner', None)
...@@ -1112,6 +1120,7 @@ static PyObject *PermissionRole_of(PermissionRole *self, PyObject *args) { ...@@ -1112,6 +1120,7 @@ static PyObject *PermissionRole_of(PermissionRole *self, PyObject *args) {
} else { } else {
result = OBJECT(r); result = OBJECT(r);
Py_INCREF(r); Py_INCREF(r);
PyErr_Clear();
} }
Py_XDECREF(r); Py_XDECREF(r);
...@@ -1130,7 +1139,7 @@ static void PermissionRole_dealloc(PermissionRole *self) { ...@@ -1130,7 +1139,7 @@ static void PermissionRole_dealloc(PermissionRole *self) {
Py_XDECREF(self->_p); Py_XDECREF(self->_p);
Py_XDECREF(self->_d); Py_XDECREF(self->__roles__);
PyMem_DEL(self); PyMem_DEL(self);
} }
...@@ -1143,7 +1152,7 @@ static PyObject *imPermissionRole_getattr(imPermissionRole *self, char *name) { ...@@ -1143,7 +1152,7 @@ static PyObject *imPermissionRole_getattr(imPermissionRole *self, char *name) {
IZZIT(_p); IZZIT(_p);
IZZIT(_pa); IZZIT(_pa);
IZZIT(_d); IZZIT(__roles__);
IZZIT(_v); IZZIT(_v);
return Py_FindAttrString(OBJECT(self), name); return Py_FindAttrString(OBJECT(self), name);
...@@ -1160,7 +1169,7 @@ static int imPermissionRole_setattr(imPermissionRole *self, char *name, ...@@ -1160,7 +1169,7 @@ static int imPermissionRole_setattr(imPermissionRole *self, char *name,
IZZITA(_p); IZZITA(_p);
IZZITA(_pa); IZZITA(_pa);
IZZITA(_d); IZZITA(__roles__);
IZZITA(_v); IZZITA(_v);
sname = PyString_FromString(name); sname = PyString_FromString(name);
...@@ -1218,7 +1227,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) { ...@@ -1218,7 +1227,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) {
*/ */
roles = PyObject_GetAttr(obj, n); roles = PyObject_GetAttr(obj, n);
if (roles == NULL) goto err; if (roles != NULL) {
if (roles == Py_None) { if (roles == Py_None) {
result = Anonymous; result = Anonymous;
...@@ -1237,7 +1246,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) { ...@@ -1237,7 +1246,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) {
if (PyTuple_Check(roles)) { if (PyTuple_Check(roles)) {
if (r == Py_None) { if (r == Py_None) {
result = roles; result = roles;
roles = NULL; /* avoid incref/decref */ roles = NULL; /* avoid inc/decref */
goto err; goto err;
} else { } else {
PyObject *list; PyObject *list;
...@@ -1300,7 +1309,8 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) { ...@@ -1300,7 +1309,8 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) {
PyObject *cat; PyObject *cat;
list = PySequence_List(roles); list = PySequence_List(roles);
cat = PySequence_Concat(r, list); cat = PySequence_Concat(r,
list);
Py_DECREF(list); Py_DECREF(list);
Py_DECREF(r); Py_DECREF(r);
...@@ -1308,6 +1318,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) { ...@@ -1308,6 +1318,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) {
} }
} }
} }
}
/*| obj = getattr(obj, 'aq_inner', None) /*| obj = getattr(obj, 'aq_inner', None)
**| if obj is None: break **| if obj is None: break
...@@ -1333,7 +1344,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) { ...@@ -1333,7 +1344,7 @@ static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *args) {
if (r == Py_None) { if (r == Py_None) {
Py_DECREF(r); Py_DECREF(r);
r = self->_d; r = self->__roles__;
if (r == NULL) goto err; if (r == NULL) goto err;
} }
...@@ -1484,8 +1495,8 @@ static void imPermissionRole_dealloc(imPermissionRole *self) { ...@@ -1484,8 +1495,8 @@ static void imPermissionRole_dealloc(imPermissionRole *self) {
Py_XDECREF(self->_pa); Py_XDECREF(self->_pa);
self->_pa = NULL; self->_pa = NULL;
Py_XDECREF(self->_d); Py_XDECREF(self->__roles__);
self->_d = NULL; self->__roles__ = NULL;
Py_XDECREF(self->_v); Py_XDECREF(self->_v);
self->_v = NULL; self->_v = NULL;
...@@ -1526,7 +1537,7 @@ static PyObject *rolesForPermissionOn(PyObject *self, PyObject *args) { ...@@ -1526,7 +1537,7 @@ static PyObject *rolesForPermissionOn(PyObject *self, PyObject *args) {
if (deflt == NULL) deflt = defaultPermission; if (deflt == NULL) deflt = defaultPermission;
im->_d = deflt; im->__roles__ = deflt;
Py_INCREF(deflt); Py_INCREF(deflt);
...@@ -1585,7 +1596,7 @@ static PyObject *permissionName(PyObject *name) { ...@@ -1585,7 +1596,7 @@ static PyObject *permissionName(PyObject *name) {
PUBLIC void initcAccessControl(void) { PUBLIC void initcAccessControl(void) {
PyObject *module; PyObject *module;
PyObject *dict; PyObject *dict;
char *rev = "$Revision: 1.5 $"; char *rev = "$Revision: 1.6 $";
if (!ExtensionClassImported) return; if (!ExtensionClassImported) return;
......
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