[Zope3-checkins] CVS: Zope3/src/zope/proxy/context - __init__.py:1.9

Jim Fulton jim@zope.com
Sun, 18 May 2003 14:06:46 -0400


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

Modified Files:
	__init__.py 
Log Message:
Updated hook configuration to use the new hooking machinery.

Also simplified hook zcml configuration. It is no longer necessary to
declare that something is hookable before hooking it. After all, we
can now introspect objects to determine if they are hookable.


=== Zope3/src/zope/proxy/context/__init__.py 1.8 => 1.9 ===
--- Zope3/src/zope/proxy/context/__init__.py:1.8	Fri May  9 10:02:55 2003
+++ Zope3/src/zope/proxy/context/__init__.py	Sun May 18 14:06:45 2003
@@ -30,20 +30,12 @@
 from zope.proxy.context.wrapper import Wrapper
 from zope.proxy.context.decorator import Decorator
 from zope.security.checker import defineChecker, selectChecker, BasicTypes
-
 from zope.proxy.interfaces.context import IContextDecorator
+from zope.hookable import hookable
 
 moduleProvides(IContextDecorator)
 
-def ContextWrapper(_ob, _parent, **kw): # hookable
-    """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 an equivalent security proxy.
-    """
-    return ContextWrapper_hook(_ob, _parent, **kw)
-
-def ContextWrapper_hook(_ob, _parent, **kw):
+def ContextWrapper(_ob, _parent, **kw):
     if type(_ob) in BasicTypes:
         # Don't wrap basic objects
         return _ob
@@ -52,14 +44,17 @@
         # insert into proxies
         checker = getChecker(_ob)
         _ob = getObject(_ob)
-        _ob = Proxy(makeWrapper_hook(_ob, _parent, kw, checker), checker)
+        _ob = Proxy(makeWrapper(_ob, _parent, kw, checker), checker)
     else:
-        _ob = makeWrapper_hook(_ob, _parent, kw)
+        _ob = makeWrapper(_ob, _parent, kw)
 
     return _ob
 
-def makeWrapper_hook(ob, parent, kw, checker=None):
+ContextWrapper = hookable(ContextWrapper)
+
+def makeWrapper(ob, parent, kw, checker=None):
     return Wrapper(ob, parent, **kw)
+makeWrapper = hookable(makeWrapper)
 
 def getWrapperObject(_ob):
     """Remove a context wrapper around an object with data