[ZPT] CVS: Zope/lib/python/ZTUtils - Tree.py:1.6.6.4

Martijn Pieters mj@zope.com
Fri, 4 Oct 2002 12:51:25 -0400


Update of /cvs-repository/Zope/lib/python/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv2550/lib/python/ZTUtils

Modified Files:
      Tag: Zope-2_6-branch
	Tree.py 
Log Message:
Merge child filter changes from trunk, update changelog message.


=== Zope/lib/python/ZTUtils/Tree.py 1.6.6.3 => 1.6.6.4 ===
--- Zope/lib/python/ZTUtils/Tree.py:1.6.6.3	Fri Oct  4 10:47:26 2002
+++ Zope/lib/python/ZTUtils/Tree.py	Fri Oct  4 12:51:24 2002
@@ -17,6 +17,7 @@
 
 from Acquisition import Explicit
 from ComputedAttribute import ComputedAttribute
+from types import ListType, TupleType
 
 class TreeNode(Explicit):
     __allow_access_to_unprotected_subobjects__ = 1
@@ -131,18 +132,21 @@
     def getChildren(self, object):
         if self._values_function is not None:
             return self._values_function(object)
-        if self._values_filter and hasattr(object, 'aq_acquire'):
-            return object.aq_acquire(self._values, aqcallback,
-                                     self._values_filter)()
-        return getattr(object, self._values)()
+
+        children = getattr(object, self._values)
+        if not (isinstance(children, ListType) or
+                isinstance(children, TupleType)):
+            # Assume callable; result not useful anyway otherwise.
+            children = children()
+
+        if self._values_filter:
+            return self._values_filter(children)
+        return children
 
 def simple_type(ob,
                 is_simple={type(''):1, type(0):1, type(0.0):1,
                            type(0L):1, type(None):1 }.has_key):
     return is_simple(type(ob))
-
-def aqcallback(self, inst, name, value, filter):
-    return filter(self, inst, name, value)
 
 from binascii import b2a_base64, a2b_base64
 from string import translate, maketrans