[Zope3-checkins] CVS: Zope3/src/zope/proxy - _zope_proxy_proxy.c:1.3 interfaces.py:1.5

Jim Fulton jim@zope.com
Wed, 28 May 2003 18:15:57 -0400


Update of /cvs-repository/Zope3/src/zope/proxy
In directory cvs.zope.org:/tmp/cvs-serv6544/src/zope/proxy

Modified Files:
	_zope_proxy_proxy.c interfaces.py 
Log Message:
Added a new introspection method, sameProxiedObjects. This can be used
to do an identity comparison of 2 proxied objects.


=== Zope3/src/zope/proxy/_zope_proxy_proxy.c 1.2 => 1.3 ===
--- Zope3/src/zope/proxy/_zope_proxy_proxy.c:1.2	Wed May 28 13:19:23 2003
+++ Zope3/src/zope/proxy/_zope_proxy_proxy.c	Wed May 28 18:15:27 2003
@@ -787,6 +787,34 @@
 }
 
 static char
+sameProxiedObjects__doc__[] = 
+"Check whether two objects are the same or proxies of the same object";
+
+static PyObject *
+wrapper_sameProxiedObjects(PyObject *unused, PyObject *args)
+{
+  PyObject *ob1, *ob2;
+
+  if (! PyArg_ParseTuple(args, "OO:sameProxiedObjects", &ob1, &ob2))
+    return NULL;
+
+  while (ob1 && Proxy_Check(ob1)) 
+    ob1 = Proxy_GET_OBJECT(ob1);
+
+  while (ob2 && Proxy_Check(ob2)) 
+    ob2 = Proxy_GET_OBJECT(ob2);
+
+  if (ob1 == ob2)
+    ob1 = Py_True;
+  else
+    ob1 = Py_False;
+
+  Py_INCREF(ob1);
+  return ob1;
+}
+
+
+static char
 queryProxy__doc__[] =
 "Look for a proxy of the given type around the object\n"
 "\n"
@@ -854,6 +882,8 @@
 module_functions[] = {
     {"getProxiedObject", wrapper_getobject, METH_O, getobject__doc__},
     {"isProxy", wrapper_isProxy, METH_VARARGS, isProxy__doc__},
+    {"sameProxiedObjects", wrapper_sameProxiedObjects, METH_VARARGS, 
+     sameProxiedObjects__doc__},
     {"queryProxy", wrapper_queryProxy, METH_VARARGS, queryProxy__doc__},
     {"queryInnerProxy", wrapper_queryInnerProxy, METH_VARARGS, 
      queryInnerProxy__doc__},


=== Zope3/src/zope/proxy/interfaces.py 1.4 => 1.5 ===
--- Zope3/src/zope/proxy/interfaces.py:1.4	Wed May 28 13:19:23 2003
+++ Zope3/src/zope/proxy/interfaces.py	Wed May 28 18:15:27 2003
@@ -30,6 +30,10 @@
         proxied by the given proxytype.
         """
 
+    def sameProxiedObjects(ob1, ob2):
+        """Check whether ob1 and ob2 are the same or proxies of the same object
+        """
+
     def getProxiedObject(obj):
         """Get the proxied Object