[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security - IChecker.py:1.1.2.6 _Proxy.c:1.1.2.5
Guido van Rossum
guido@python.org
Thu, 18 Apr 2002 14:11:26 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv5653
Modified Files:
Tag: SecurityProxy-branch
IChecker.py _Proxy.c
Log Message:
Add and test check_setattr().
=== Zope3/lib/python/Zope/Security/IChecker.py 1.1.2.5 => 1.1.2.6 ===
"""
+ def check_setattr(ob, name):
+ """Check whether attribute assignment is allowed
+ """
+
def check_getitem(ob, key):
"""Check whether an item access is allowed
"""
=== Zope3/lib/python/Zope/Security/_Proxy.c 1.1.2.4 => 1.1.2.5 ===
proxy_setattro(PyObject *self, PyObject *name, PyObject *value)
{
- return PyObject_SetAttr(Proxy_GetObject(self), name, value);
+ PyObject *object = Proxy_GetObject(self);
+ PyObject *checker = Proxy_GetChecker(self);
+ PyObject *checked;
+
+ /*
+ * checked = checker.check_setattr(object, name)
+ * setattr(object, name, value)
+ */
+ checked = PyObject_CallMethod(
+ checker, "check_setattr", "(OO)", object, name);
+ if (checked == NULL)
+ return -1;
+ Py_DECREF(checked);
+ return PyObject_SetAttr(object, name, value);
}
static PyObject *