[Zope-Checkins] CVS: Zope3/lib/python/Zope/App - ITraversable.py:1.1.2.2 Traversable.py:1.1.2.3

Martijn Pieters mj@zope.com
Mon, 3 Dec 2001 11:42:34 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	ITraversable.py Traversable.py 
Log Message:
- Register Traversable as a feature.

- Do the right thing for unwrapped objects.


=== Zope3/lib/python/Zope/App/ITraversable.py 1.1.2.1 => 1.1.2.2 ===
     def getPhysicalRoot():
         """
-        Returns the top-level Application object.
+        Returns the top-level Application object, or the bas eobject is it is
+        unwrapped.
         """
 
     def getPhysicalPath():
@@ -24,7 +25,8 @@
         Returns a path (an immutable sequence of strings) from the root.
         
         This path can be used to access this object again later, for example in
-        a copy/paste operation.
+        a copy/paste operation. Returns an empty tuple if the base object is not
+        wrapped.
         """
     
     def unrestrictedTraverse(path, default=_RAISE_KEYERROR):


=== Zope3/lib/python/Zope/App/Traversable.py 1.1.2.2 => 1.1.2.3 ===
     __implements__ = ITraversable
 
-    __used_for__ = IWrapper
+    # XXX: This is wishful thinking, as it doesn't work like this yet
+    #      Arguably this feature should work for unwrapper objecs as well.
+    # __used_for__ = IWrapper
 
     def __init__(self, wrapper):
         self._wrapper = wrapper
@@ -40,7 +42,8 @@
         path = []
         
         for w in WrapperChain(self._wrapper):
-            path.insert(0, wrapper.getdict(w)['name'])
+            d = wrapper.getdict(w)
+            if d: path.insert(0, d['name'])
 
         return tuple(path)