[ZPT] CVS: Zope/lib/python/ZTUtils - Tree.py:1.10
Martijn Pieters
mj@zope.com
Fri, 4 Oct 2002 12:50:59 -0400
Update of /cvs-repository/Zope/lib/python/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv2272/lib/python/ZTUtils
Modified Files:
Tree.py
Log Message:
Make the optional children filter work in accordance with the documentation
string of setChildAccess. This is quite different from the old
implementation, but as that old implementation never worked anyway, this
change won't break any code elsewhere.
=== Zope/lib/python/ZTUtils/Tree.py 1.9 => 1.10 ===
--- Zope/lib/python/ZTUtils/Tree.py:1.9 Fri Oct 4 10:47:54 2002
+++ Zope/lib/python/ZTUtils/Tree.py Fri Oct 4 12:50:58 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