[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/security/ Merged from branch:

Jim Fulton jim at zope.com
Fri Jul 23 12:22:57 EDT 2004


Log message for revision 26705:
  Merged from branch:
  
    r26665 | jim | 2004-07-21 18:49:38 -0400 (Wed, 21 Jul 2004) | 6 lines
  
  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/branches/ZopeX3-3.0/src/zope/security/_proxy.c
  U   Zope3/branches/ZopeX3-3.0/src/zope/security/proxy.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_proxy.py


-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/security/_proxy.c
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/security/_proxy.c	2004-07-23 16:16:30 UTC (rev 26704)
+++ Zope3/branches/ZopeX3-3.0/src/zope/security/_proxy.c	2004-07-23 16:22:56 UTC (rev 26705)
@@ -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/branches/ZopeX3-3.0/src/zope/security/proxy.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/security/proxy.py	2004-07-23 16:16:30 UTC (rev 26704)
+++ Zope3/branches/ZopeX3-3.0/src/zope/security/proxy.py	2004-07-23 16:22:56 UTC (rev 26705)
@@ -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/branches/ZopeX3-3.0/src/zope/security/tests/test_proxy.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_proxy.py	2004-07-23 16:16:30 UTC (rev 26704)
+++ Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_proxy.py	2004-07-23 16:22:56 UTC (rev 26705)
@@ -12,8 +12,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