[Zope3-checkins] CVS: Zope3/src/zope/app - context.py:1.11
Jim Fulton
jim@zope.com
Tue, 1 Jul 2003 19:29:13 -0400
Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv6221/app
Modified Files:
context.py
Log Message:
Fixed a context wrapping bug. We were getting multiple levels of
proxies for the same object and container due to wrapping by
decorators and the publisher. The logic for detecting duplicate
wrapping was fooled by the security wrapper around the container that
wasn't in the context of the already wrapped object.
=== Zope3/src/zope/app/context.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/context.py:1.10 Fri Jun 20 02:59:08 2003
+++ Zope3/src/zope/app/context.py Tue Jul 1 19:28:42 2003
@@ -28,7 +28,7 @@
from zope.interface.declarations import ObjectSpecification
from zope.interface.declarations import ObjectSpecificationDescriptor
from zope.interface import moduleProvides, implements, providedBy
-from zope.proxy import queryProxy, getProxiedObject
+from zope.proxy import queryProxy, getProxiedObject, sameProxiedObjects
from zope.security.checker import defineChecker, BasicTypes
from zope.security.checker import selectChecker, CombinedChecker, NoProxy
from zope.security.proxy import Proxy, getChecker
@@ -133,9 +133,26 @@
wrapper = queryProxy(_ob, Wrapper)
if wrapper is not None: # using kw as marker
- if _parent is getcontext(wrapper):
+ wrappercontext = getcontext(wrapper)
+
+
+ if (_parent is wrappercontext
+
+ # Check after removing a security proxy
+ or
+ (sameProxiedObjects(_parent, wrappercontext)
+ and
+ issubclass(type(_parent), Proxy)
+ and
+ getProxiedObject(_parent) is wrappercontext
+ )
+ ):
+
# This would be a redundant wrapper. We'll just use the
# one we've got.
+
+ if wrappercontext is not _parent:
+ setcontext(wrapper, _parent)
# But we want tp make sure we have the same data
if kw: