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

Guido van Rossum guido@python.org
Thu, 18 Apr 2002 15:04:36 -0400


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

Modified Files:
      Tag: SecurityProxy-branch
	_Proxy.c 
Log Message:
Simplify the check_{get,set}item signatures.
Add reminders of checkers not yet called.
Standardize comment style.


=== Zope3/lib/python/Zope/Security/_Proxy.c 1.1.2.7 => 1.1.2.8 ===
+/*
+ * Security proxy.
+ */
 
 #include <Python.h>
 
@@ -56,7 +58,7 @@
 
 
 /*
- *   Slot methods.
+ * Slot methods.
  */
 
 static PyObject *
@@ -81,6 +83,14 @@
 	return (PyObject *)self;
 }
 
+static void
+proxy_dealloc(PyObject *self)
+{
+	Py_DECREF(Proxy_GetObject(self));
+	Py_DECREF(Proxy_GetChecker(self));
+	self->ob_type->tp_free(self);
+}
+
 static int
 proxy_traverse(PyObject *self, visitproc visit, void *arg)
 {
@@ -93,29 +103,21 @@
 static PyObject *
 proxy_richcompare(PyObject* self, PyObject* other, int op)
 {
-	while (Proxy_Check(self)) {
+	/* XXX check_richcompare */
+	if (Proxy_Check(self))
 		self = Proxy_GetObject(self);
-	}
-	while (Proxy_Check(other)) {
+	if (Proxy_Check(other))
 		other = Proxy_GetObject(other);
-	}
 	return PyObject_RichCompare(self, other, op);
 }
 
 static PyObject *
 proxy_iter(PyObject *self)
 {
+	/* XXX check_iter */
 	return PyObject_GetIter(Proxy_GetObject(self));
 }
 
-static void
-proxy_dealloc(PyObject *self)
-{
-	Py_DECREF(Proxy_GetObject(self));
-	Py_DECREF(Proxy_GetChecker(self));
-	self->ob_type->tp_free(self);
-}
-
 static PyObject *
 proxy_getattro(PyObject *self, PyObject *name)
 {
@@ -177,12 +179,14 @@
 static int
 proxy_compare(PyObject *proxy, PyObject *v)
 {
+	/* XXX check_compare */
 	return PyObject_Compare(Proxy_GetObject(proxy), v);
 }
 
 static long
 proxy_hash(PyObject *self)
 {
+	/* XXX check_hash */
 	return PyObject_Hash(Proxy_GetObject(self));
 }
 
@@ -213,48 +217,53 @@
 }
 
 /*
- *   Number methods
- *   XXX need more :-)
+ * Number methods.
+ * XXX need more :-)
  */
 
 static int
 proxy_nonzero(PyObject *self)
 {
+	/* XXX check_nonzero */
 	return PyObject_IsTrue(Proxy_GetObject(self));
 }
 
 /*
- *   Sequence methods
- *   (If you have mapping getitem/setitem, sequence getitem/setitem
- *   never get called.)
+ * Sequence methods.
+ * (If you have mapping getitem/setitem, sequence getitem/setitem
+ * never get called.)
  */
 
 static int
 proxy_length(PyObject *self)
 {
+	/* XXX check_len */
 	return PyObject_Length(Proxy_GetObject(self));
 }
 
 static PyObject *
 proxy_slice(PyObject *self, int start, int end)
 {
+	/* XXX check_getslice */
 	return PySequence_GetSlice(Proxy_GetObject(self), start, end);
 }
 
 static int
 proxy_ass_slice(PyObject *self, int i, int j, PyObject *value)
 {
+	/* XXX check_setslice */
 	return PySequence_SetSlice(Proxy_GetObject(self), i, j, value);
 }
 
 static int
 proxy_contains(PyObject *self, PyObject *value)
 {
+	/* XXX check_contains */
 	return PySequence_Contains(Proxy_GetObject(self), value);
 }
 
 /*
- *   Mapping methods
+ * Mapping methods.
  */
 
 static PyObject *
@@ -271,7 +280,7 @@
 	 * return checker.proxy(value, checked)
 	 */
 	checked = PyObject_CallMethod(
-		checker, "check_getitem", "(OO)", object, key);
+		checker, "check_getitem", "(O)", object);
 	if (checked != NULL) {
 		value = PyObject_GetItem(object, key);
 		if (value != NULL) {
@@ -296,7 +305,7 @@
 	 * object[key] = value
 	 */
 	checked = PyObject_CallMethod(
-		checker, "check_setitem", "(OO)", object, key);
+		checker, "check_setitem", "(O)", object);
 	if (checked == NULL)
 		return -1;
 	Py_DECREF(checked);
@@ -304,7 +313,7 @@
 }
 
 /*
- *   Normal methods
+ * Normal methods.
  */
 
 static PyNumberMethods
@@ -340,10 +349,6 @@
 	proxy_getitem,				/* mp_subscript */
 	proxy_setitem,				/* mp_ass_subscript */
 };
-
-/*
- * XXX Numeric methods are not yet supported.
- */
 
 statichere PyTypeObject
 ProxyType = {