[Zope3-checkins] CVS: Zope3/src/zope/app/tests - test_context.py:1.5

Jim Fulton jim@zope.com
Tue, 1 Jul 2003 19:28:43 -0400


Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv6221/app/tests

Modified Files:
	test_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/tests/test_context.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/tests/test_context.py:1.4	Mon Jun  2 15:41:14 2003
+++ Zope3/src/zope/app/tests/test_context.py	Tue Jul  1 19:28:42 2003
@@ -354,6 +354,31 @@
     <class 'zope.security.checker.Checker'>
     """
 
+def test_avoiding_redundant_wrappers_in_presence_of_security_proxy():
+    """
+    >>> from zope.security.checker import ProxyFactory
+    >>> from zope.context import getWrapperData
+    >>> from zope.app.context import Wrapper, ContextWrapper
+    >>> from zope.proxy import ProxyIterator
+    >>> class X:
+    ...     pass
+    >>> parent = X()
+    >>> child = X()
+    >>> wrapped_child = Wrapper(child, parent, x=1)
+    >>> proxied_parent = ProxyFactory(parent)
+    >>> rewrapped = ContextWrapper(wrapped_child, proxied_parent, y=2)
+    >>> len(list(ProxyIterator(rewrapped)))
+    2
+    >>> rewrapped is wrapped_child
+    1
+    >>> l = list(getWrapperData(rewrapped).items())
+    >>> l.sort()
+    >>> l
+    [('x', 1), ('y', 2)]
+    
+    """
+
+
 def test_suite():
     suite = DocTestSuite()
     suite.addTest(DocTestSuite('zope.app.context'))