[Zope3-checkins] SVN: Zope3/trunk/src/zope/security/ Added (back) a getObject _proxy module method to unproxy an object only if it

Jim Fulton jim at zope.com
Wed Jul 21 18:49:38 EDT 2004


Log message for revision 26665:
  Added (back) a getObject _proxy module method to unproxy an object only if it
  is in a security proxy.
  
  Changed zope.security.proxy.getProxiedObject to use the new getObject
  method.
  


Changed:
  U   Zope3/trunk/src/zope/security/_proxy.c
  U   Zope3/trunk/src/zope/security/proxy.py
  U   Zope3/trunk/src/zope/security/tests/test_proxy.py


-=-
Modified: Zope3/trunk/src/zope/security/_proxy.c
===================================================================
--- Zope3/trunk/src/zope/security/_proxy.c	2004-07-21 22:20:42 UTC (rev 26664)
+++ Zope3/trunk/src/zope/security/_proxy.c	2004-07-21 22:49:38 UTC (rev 26665)
@@ -885,9 +885,25 @@
   return result;
 }
 
+static PyObject *
+module_getObject(PyObject *self, PyObject *arg)
+{
+  PyObject *result;
+
+  if (!Proxy_Check(arg))
+    result = arg;
+  else
+    result = ((SecurityProxy*)arg)->proxy.proxy_object;
+  
+  Py_INCREF(result);
+  return result;
+}
+
 static PyMethodDef
 module_functions[] = {
   {"getChecker", module_getChecker, METH_O, "get checker from proxy"},
+  {"getObject", module_getObject, METH_O, 
+   "Get the proxied object\n\nReturn the original object if not proxied."},
   {NULL}
 };
 

Modified: Zope3/trunk/src/zope/security/proxy.py
===================================================================
--- Zope3/trunk/src/zope/security/proxy.py	2004-07-21 22:20:42 UTC (rev 26664)
+++ Zope3/trunk/src/zope/security/proxy.py	2004-07-21 22:49:38 UTC (rev 26665)
@@ -15,11 +15,13 @@
 
 $Id$
 """
-from zope.proxy import getProxiedObject
-from zope.security._proxy import getChecker
+
+from zope.security._proxy import getChecker, getObject
 from zope.security._proxy import _Proxy as Proxy
 from zope.security.checker import TrustedCheckerBase
 
+getProxiedObject = getObject
+
 # This import represents part of the API for this module
 from zope.security.checker import ProxyFactory
 

Modified: Zope3/trunk/src/zope/security/tests/test_proxy.py
===================================================================
--- Zope3/trunk/src/zope/security/tests/test_proxy.py	2004-07-21 22:20:42 UTC (rev 26664)
+++ Zope3/trunk/src/zope/security/tests/test_proxy.py	2004-07-21 22:49:38 UTC (rev 26665)
@@ -17,8 +17,8 @@
 """
 
 import unittest
-from zope.security.proxy import getChecker, ProxyFactory
-from zope.proxy import ProxyBase as proxy, getProxiedObject
+from zope.security.proxy import getChecker, ProxyFactory, getProxiedObject
+from zope.proxy import ProxyBase as proxy
 
 class Checker(object):
 



More information about the Zope3-Checkins mailing list