[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper - wrapper.c:1.12.2.4
Fred Drake Jr
fdrake@acm.org
Wed, 28 Nov 2001 17:48:37 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper
In directory cvs.zope.org:/tmp/cvs-serv300
Modified Files:
Tag: Zope-3x-branch
wrapper.c
Log Message:
Add getinnerwrapper().
=== Zope3/lib/python/Zope/ContextWrapper/wrapper.c 1.12.2.3 => 1.12.2.4 ===
static PyObject *
+api_getinnerwrapper(PyObject *obj)
+{
+ PyObject *temp;
+ if (obj == NULL)
+ return missing_wrapper("getinnercontext");
+ if (Wrapper_Check(obj)) {
+ temp = Wrapper_GetObject(obj);
+ while (Wrapper_Check(temp)) {
+ obj = temp;
+ temp = Wrapper_GetObject(obj);
+ }
+ }
+ else
+ return NULL;
+ return obj;
+}
+
+static PyObject *
api_getdict(PyObject *wrapper)
{
if (wrapper == NULL)
@@ -503,6 +521,7 @@
api_getbaseobject,
api_getcontext,
api_getinnercontext,
+ api_getinnerwrapper,
api_getdict,
api_getdictcreate,
api_setobject,
@@ -588,6 +607,24 @@
}
static char
+getinnerwrapper__doc__[] =
+"getinnerwrapper(wrapper) --> object | None\n"
+"\n"
+"Return the innermost wrapper in a chain of wrappers with 'wrapper' at the\n"
+"head, or None if there isn't one. Returns None if 'wrapper' isn't a\n"
+"wrapper at all.";
+
+static PyObject *
+wrapper_getinnerwrapper(PyObject *unused, PyObject *obj)
+{
+ PyObject *result = api_getinnerwrapper(obj);
+ if (result == NULL)
+ result = obj;
+ Py_INCREF(result);
+ return result;
+}
+
+static char
getdict__doc__[] =
"getdict(wrapper) -> dict or None\n"
"\n"
@@ -686,6 +723,8 @@
getcontext__doc__},
{"getinnercontext", wrapper_getinnercontext, METH_O,
getinnercontext__doc__},
+ {"getinnerwrapper", wrapper_getinnerwrapper, METH_O,
+ getinnerwrapper__doc__},
{"getdict", wrapper_getdict, METH_O,
getdict__doc__},
{"getdictcreate", wrapper_getdictcreate, METH_O,