[Checkins] SVN: z3c.jsontree/trunk/ Fix: getParentsFromContextToObject, don't return a parent chain if an item

Roger Ineichen roger at projekt01.ch
Tue Mar 10 22:16:33 EDT 2009


Log message for revision 97820:
  Fix: getParentsFromContextToObject, don't return a parent chain if an item 
  is a location proxied NotFound error object. It's possible that such a
  NotFound object will wrap a context which we don't allow in our parent
  chain at all.

Changed:
  U   z3c.jsontree/trunk/CHANGES.txt
  U   z3c.jsontree/trunk/src/z3c/jsontree/base.py
  U   z3c.jsontree/trunk/src/z3c/jsontree/util.py

-=-
Modified: z3c.jsontree/trunk/CHANGES.txt
===================================================================
--- z3c.jsontree/trunk/CHANGES.txt	2009-03-10 21:13:57 UTC (rev 97819)
+++ z3c.jsontree/trunk/CHANGES.txt	2009-03-11 02:16:33 UTC (rev 97820)
@@ -5,7 +5,10 @@
 0.5.2 (unreleased)
 ------------------
 
-- ...
+- Fix: getParentsFromContextToObject, don't return a parent chain if an item 
+  is a location proxied NotFound error object. It's possible that such a
+  NotFound object will wrap a context which we don't allow in our parent
+  chain at all.
 
 0.5.1 (2009-03-10)
 ------------------

Modified: z3c.jsontree/trunk/src/z3c/jsontree/base.py
===================================================================
--- z3c.jsontree/trunk/src/z3c/jsontree/base.py	2009-03-10 21:13:57 UTC (rev 97819)
+++ z3c.jsontree/trunk/src/z3c/jsontree/base.py	2009-03-11 02:16:33 UTC (rev 97820)
@@ -123,11 +123,16 @@
         return util.getIconURL(item, request, name=name)
 
     def getParents(self):
+        """This method returns a parent chain.
+        
+        The method is also responsible for skip objects which should get
+        excluded e.g. the sitemanager items.
+        """
         root = self.getRoot()
         return util.getParentsFromContextToObject(self.context, root)
 
     def update(self):
-        """Returns HTML code for representing a <ul> tag tree with the 
+        """Update HTML code for representing a <ul> tag tree with the 
         siblings and parents of an object.
 
         There is only one branch expanded, in other words, the tree is

Modified: z3c.jsontree/trunk/src/z3c/jsontree/util.py
===================================================================
--- z3c.jsontree/trunk/src/z3c/jsontree/util.py	2009-03-10 21:13:57 UTC (rev 97819)
+++ z3c.jsontree/trunk/src/z3c/jsontree/util.py	2009-03-11 02:16:33 UTC (rev 97820)
@@ -17,7 +17,8 @@
 __docformat__ = 'restructuredtext'
 
 import zope.component
-from zope.traversing import api
+import zope.traversing.api
+import zope.publisher.interfaces
 from zope.proxy import sameProxiedObjects
 from zope.traversing.interfaces import TraversalError
 
@@ -36,7 +37,7 @@
 def isChildOf(child, parent):
     """Check if object is a child of the parent."""
     try:
-        if parent in api.getParents(child):
+        if parent in zope.traversing.api.getParents(child):
             return True
         else:
             return False
@@ -51,6 +52,12 @@
     If the child object is not a child of the parent a empty list
     will return.
     """
+    # this is a very bad situation. The context could be a NotFound error.
+    # Such NotFound objects provide a LocationProxy with the site as parent
+    # even if we don't allow the site in our possible parent chain. So skip it.
+    if zope.publisher.interfaces.INotFound.providedBy(context):
+        return []
+
     if not isChildOf(context, obj):
         return []
     



More information about the Checkins mailing list