[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security - _Proxy.c:1.1.2.7

Guido van Rossum guido@python.org
Thu, 18 Apr 2002 14:39:53 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv18165

Modified Files:
      Tag: SecurityProxy-branch
	_Proxy.c 
Log Message:
Support check_call.


=== Zope3/lib/python/Zope/Security/_Proxy.c 1.1.2.6 => 1.1.2.7 ===
 
 static PyObject *
-proxy_call(PyObject *self, PyObject *args, PyObject *kw)
+proxy_call(PyObject *self, PyObject *args, PyObject *kwds)
 {
-	if (kw)
-		return PyEval_CallObjectWithKeywords(Proxy_GetObject(self),
-						     args, kw);
-	else
-		return PyObject_CallObject(Proxy_GetObject(self), args);
+	PyObject *result = NULL;
+	PyObject *object = Proxy_GetObject(self);
+	PyObject *checker = Proxy_GetChecker(self);
+	PyObject *checked, *value;
+
+	/*
+	 * checked = checker.check_call(object)
+	 * value = object(*args, **kwds)
+	 * return checker.proxy(value, checked)
+	 */
+	checked = PyObject_CallMethod(checker, "check_call", "(O)", object);
+	if (checked != NULL) {
+		value = PyObject_Call(object, args, kwds);
+		if (value != NULL) {
+			result = PyObject_CallMethod(
+				checker, "proxy", "(OO)", value, checked);
+			Py_DECREF(value);
+		}
+		Py_DECREF(checked);
+	}
+	return result;
 }
 
 /*