[ZPT] CVS: Zope/lib/python/ZTUtils - Tree.py:1.4.14.2
Martijn Pieters
mj@zope.com
Fri, 4 Oct 2002 12:51:44 -0400
Update of /cvs-repository/Zope/lib/python/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv2583/lib/python/ZTUtils
Modified Files:
Tag: Zope-2_5-branch
Tree.py
Log Message:
Merge child filter changes from trunk, update changelog message.
=== Zope/lib/python/ZTUtils/Tree.py 1.4.14.1 => 1.4.14.2 ===
--- Zope/lib/python/ZTUtils/Tree.py:1.4.14.1 Fri Oct 4 11:01:37 2002
+++ Zope/lib/python/ZTUtils/Tree.py Fri Oct 4 12:51:43 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
import string