[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Traversing - Traverser.py:1.1.2.9

Steve Alexander steve@cat-box.net
Wed, 17 Apr 2002 18:33:30 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Traversing
In directory cvs.zope.org:/tmp/cvs-serv20787/lib/python/Zope/App/Traversing

Modified Files:
      Tag: Zope-3x-branch
	Traverser.py 
Log Message:
Amended various modules to import Wrapper, getdict and getcontext from
Zope.ContextWrapper rather than Zope.ContextWrapper.wrapper

Added a SimpleMethodWrapper, which is a rather hacky python way of
rebinding methods so that the im_self gets wrapped.

Now, you'll get a SimpleMethodWrapper rather than a Wrapper when you
say from Zope.ContextWrapper import Wrapper

You say that a particular method should get its im_self rebound by
making it into a ContextMethod, in a similar way to making a staticmethod
or a classmethod.

See the testSimpleMethodWrapper.py module for an example.



=== Zope3/lib/python/Zope/App/Traversing/Traverser.py 1.1.2.8 => 1.1.2.9 ===
 from ITraversable import ITraversable
 from Zope.ContextWrapper.IWrapper import IWrapper
-from Zope.ContextWrapper import wrapper
+from Zope.ContextWrapper import getcontext, getdict, Wrapper
 from Zope.ComponentArchitecture import getAdapter
 from Zope.Exceptions import NotFoundError, Unauthorized
 from Zope.App.Security.SecurityManagement import getSecurityManager
@@ -32,7 +32,7 @@
 def WrapperChain(w):
     while w is not None:
         yield w
-        w = wrapper.getcontext(w)
+        w = getcontext(w)
 
 _marker = object()
 
@@ -58,7 +58,7 @@
         path = []
         
         for w in WrapperChain(self._wrapper):
-            d = wrapper.getdict(w)
+            d = getdict(w)
             if d:
                 path.insert(0, d['name'])
 
@@ -97,7 +97,7 @@
                     continue
 
                 if name == '..':
-                    curr = wrapper.getcontext(curr) or curr
+                    curr = getcontext(curr) or curr
                     if restricted:
                         validate(None, curr)
                     continue
@@ -107,7 +107,7 @@
                     raise NotFoundError, 'No traversable adapter found'
 
                 next = traversable.traverse(name, path)
-                curr = wrapper.Wrapper(next, curr, name=name)
+                curr = Wrapper(next, curr, name=name)
                 if restricted:
                     validate(name, curr)