[Zope-Checkins] CVS: Zope3/lib/python/Zope/Proxy - ContextWrapper.py:1.5

Jim Fulton jim@zope.com
Sat, 13 Jul 2002 10:18:38 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Proxy
In directory cvs.zope.org:/tmp/cvs-serv1111/lib/python/Zope/Proxy

Modified Files:
	ContextWrapper.py 
Log Message:
Fixed bug in context management when uri segments that produce only
side effects (e.g. ++skin++ZopeTop) are used.

Fixed up absolute url bread crumbs to not show side-effect steps in
bread crumbs, while retaining them in the breadcrumb urls.

Refactored side-effect handling slightly (changed context data names)
in absolute url and physical path code.

Added tests for side effect handling for absolute url, physical path,
and namespace handling code.


=== Zope3/lib/python/Zope/Proxy/ContextWrapper.py 1.4 => 1.5 ===
     """Create a context wrapper around an object with data
 
     If the object is wrapped in a security proxy, then the context
-    wrapper is inserted inside the security proxy.
+    wrapper is inserted inside an equivalent security proxy.
     """
     
     if type(_ob) in BasicTypes:
@@ -46,6 +46,26 @@
         _ob = Proxy(_Wrapper(_ob, _parent, **kw), checker)
     else:
         _ob = _Wrapper(_ob, _parent, **kw)
+        
+    return _ob
+
+def getWrapperObject(_ob):
+    """Remove a context wrapper around an object with data
+
+    If the object is wrapped in a security proxy, then the object
+    is inserted inside an equivalent  security proxy.
+    """
+    
+    if type(_ob) in BasicTypes:
+        # Don't wrap basic objects
+        return _ob
+    elif type(_ob) is Proxy:
+        # insert into proxies
+        checker = getChecker(_ob)
+        _ob = getObject(_ob)
+        _ob = Proxy(getobject(_ob), checker)
+    else:
+        _ob = getobject(_ob)
         
     return _ob