[Zope3-checkins] CVS: Zope3/src/zope/context - __init__.py:1.19 interfaces.py:1.12

Jim Fulton jim@zope.com
Sun, 1 Jun 2003 12:00:10 -0400


Update of /cvs-repository/Zope3/src/zope/context
In directory cvs.zope.org:/tmp/cvs-serv25908/src/zope/context

Modified Files:
	__init__.py interfaces.py 
Log Message:
Moved ContextWrapper, getItem, getAttr, queryItem, and queryAttr
from zope.context to zope.app.context.


=== Zope3/src/zope/context/__init__.py 1.18 => 1.19 ===
--- Zope3/src/zope/context/__init__.py:1.18	Wed May 28 19:15:26 2003
+++ Zope3/src/zope/context/__init__.py	Sun Jun  1 11:59:40 2003
@@ -22,51 +22,18 @@
 
 __metaclass__ = type
 
-
 from zope.interface import moduleProvides
-from zope.security.proxy import Proxy, getChecker
 from zope.context.wrapper import getdict, getdictcreate
 from zope.context.wrapper import getcontext, getinnercontext
 from zope.context.wrapper import getinnerwrapper, getbaseobject
 from zope.context.wrapper import ContextDescriptor, ContextAware
 from zope.context.wrapper import ContextMethod, ContextProperty
 from zope.context.wrapper import Wrapper
-from zope.security.checker import defineChecker, selectChecker, BasicTypes
 from zope.proxy import queryProxy, queryInnerProxy, isProxy, getProxiedObject
-from zope.context.interfaces import IContextWrapper
-from zope.hookable import hookable
-
-moduleProvides(IContextWrapper)
-__all__ = tuple(IContextWrapper)
+from zope.context.interfaces import IWrapperIntrospection
 
-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)
-        _ob = getProxiedObject(_ob)
-        _ob = Proxy(Wrapper(_ob, _parent, **kw), checker)
-    else:
-        _ob = Wrapper(_ob, _parent, **kw)
-
-    return _ob
-ContextWrapper = hookable(ContextWrapper)
+moduleProvides(IWrapperIntrospection)
+__all__ = tuple(IWrapperIntrospection)
 
 def getWrapperData(_ob, create=False):
     wrapper = queryProxy(_ob, Wrapper)
@@ -123,26 +90,6 @@
         wrapper = queryProxy(obj, Wrapper)
 
     yield obj
-
-def getItem(collection, name):
-    return ContextWrapper(collection[name], collection, name=name)
-
-def getAttr(collection, name):
-    return ContextWrapper(getattr(collection, name), collection, name=name)
-
-def queryItem(collection, name, default=None):
-    return ContextWrapper(collection.get(name, default),
-                          collection, name=name)
-
-def queryAttr(collection, name, default=None):
-    return ContextWrapper(getattr(collection, name, default),
-                          collection, name=name)
-
-
-# XXX Do I actually need these?
-def _contextWrapperChecker(ob):
-    return selectChecker(getProxiedObject(ob))
-defineChecker(Wrapper, _contextWrapperChecker)
 
 class ContextSuper:
 


=== Zope3/src/zope/context/interfaces.py 1.11 => 1.12 ===
--- Zope3/src/zope/context/interfaces.py:1.11	Wed May 28 11:47:48 2003
+++ Zope3/src/zope/context/interfaces.py	Sun Jun  1 11:59:40 2003
@@ -118,22 +118,8 @@
         """Raises AttributeError if called (to prevent pickling)"""
 
 
-class IContextWrapper(Interface):
+class IWrapperIntrospection(Interface):
     """Wrapper API provided to applications."""
-
-    def ContextWrapper(object, parent, **data):
-        """Create a context wrapper for object in parent
-
-        If the object is in a security proxy, then result will be
-        a security proxy for the unproxied object in context.
-
-        Consider an object, o1, in a proxy p1 with a checker c1.
-
-        If we call ContextWrapper(p1, parent, name='foo'), then we'll
-        get::
-
-          Proxy(Wrapper(o1, parent, name='foo'), c1)
-        """
 
     def getWrapperData(ob):
         """Get the context wrapper data for an object"""