[Zope3-checkins] CVS: Zope3/src/zope/context - __init__.py:1.18
Jim Fulton
jim@zope.com
Wed, 28 May 2003 19:15:57 -0400
Update of /cvs-repository/Zope3/src/zope/context
In directory cvs.zope.org:/tmp/cvs-serv15295/src/zope/context
Modified Files:
__init__.py
Log Message:
Added logic to ContextWrapper to avoid some redundant wrapping.
Removed the unused getWrapperObject function.
=== Zope3/src/zope/context/__init__.py 1.17 => 1.18 ===
--- Zope3/src/zope/context/__init__.py:1.17 Wed May 28 13:19:22 2003
+++ Zope3/src/zope/context/__init__.py Wed May 28 19:15:26 2003
@@ -40,10 +40,23 @@
__all__ = tuple(IContextWrapper)
def ContextWrapper(_ob, _parent, **kw):
+
if type(_ob) in BasicTypes:
# Don't wrap basic objects
return _ob
+ wrapper = queryProxy(_ob, Wrapper, kw)
+ if wrapper is not kw: # using kw as marker
+ if _parent is getcontext(wrapper):
+ # This would be a redundant wrapper. We'll just use the
+ # one we've got.
+
+ # But we want tp make sure we have the same data
+ if kw:
+ dict = getdictcreate(wrapper)
+ dict.update(kw)
+ return _ob
+
if type(_ob) is Proxy:
# insert into proxies
checker = getChecker(_ob)
@@ -54,27 +67,6 @@
return _ob
ContextWrapper = hookable(ContextWrapper)
-
-
-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 = getProxiedObject(_ob)
- _ob = Proxy(getProxiedObject(_ob), checker)
- else:
- _ob = getProxiedObject(_ob)
-
- return _ob
def getWrapperData(_ob, create=False):
wrapper = queryProxy(_ob, Wrapper)