[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper - wrapper.c:1.12.2.3
Fred Drake Jr
fdrake@acm.org
Wed, 28 Nov 2001 16:56:25 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper
In directory cvs.zope.org:/tmp/cvs-serv21426/Zope/ContextWrapper
Modified Files:
Tag: Zope-3x-branch
wrapper.c
Log Message:
Change getinnerobject() to getbaseobject() to better conform to current
expectations from the acquisition world.
Add basic support for rich comparisons.
=== Zope3/lib/python/Zope/ContextWrapper/wrapper.c 1.12.2.2 => 1.12.2.3 ===
+static PyObject *api_getbaseobject(PyObject *obj);
+
static PyObject *
empty_tuple = NULL;
@@ -80,6 +82,14 @@
return 0;
}
+static PyObject *
+wrap_richcompare(PyObject* self, PyObject* other, int op)
+{
+ self = api_getbaseobject(self);
+ other = api_getbaseobject(other);
+ return PyObject_RichCompare(self, other, op);
+}
+
static void
wrap_dealloc(PyObject *self)
{
@@ -289,7 +299,7 @@
0, /* tp_doc */
wrap_traverse, /* tp_traverse */
wrap_clear, /* tp_clear */
- 0, /* tp_richcompare */
+ wrap_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
@@ -383,10 +393,10 @@
}
static PyObject *
-api_getinnerobject(PyObject *obj)
+api_getbaseobject(PyObject *obj)
{
if (obj == NULL)
- return missing_wrapper("getinnerobject");
+ return missing_wrapper("getbaseobject");
while (Wrapper_Check(obj)) {
obj = Wrapper_GetObject(obj);
}
@@ -490,7 +500,7 @@
api_check,
api_create,
api_getobject,
- api_getinnerobject,
+ api_getbaseobject,
api_getcontext,
api_getinnercontext,
api_getdict,
@@ -519,17 +529,17 @@
}
static char
-getinnerobject__doc__[] =
-"getinnerobject(wrapper) --> object\n"
+getbaseobject__doc__[] =
+"getbaseobject(wrapper) --> object\n"
"\n"
"Return the underlying object for the innermost wrapper in a chain of\n"
"wrappers with 'wrapper' at the head. Returns None if 'wrapper' isn't a\n"
"wrapper at all.";
static PyObject *
-wrapper_getinnerobject(PyObject *unused, PyObject *obj)
+wrapper_getbaseobject(PyObject *unused, PyObject *obj)
{
- obj = api_getinnerobject(obj);
+ obj = api_getbaseobject(obj);
if (obj == NULL)
obj = Py_None;
Py_INCREF(obj);
@@ -670,8 +680,8 @@
module_functions[] = {
{"getobject", wrapper_getobject, METH_O,
getobject__doc__},
- {"getinnerobject", wrapper_getinnerobject, METH_O,
- getinnerobject__doc__},
+ {"getbaseobject", wrapper_getbaseobject, METH_O,
+ getbaseobject__doc__},
{"getcontext", wrapper_getcontext, METH_O,
getcontext__doc__},
{"getinnercontext", wrapper_getinnercontext, METH_O,