Commit b97ee087 authored by Martijn Pieters's avatar Martijn Pieters

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.
parent 87124e6b
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
############################################################################## ##############################################################################
__doc__='''Tree manipulation classes __doc__='''Tree manipulation classes
$Id: Tree.py,v 1.9 2002/10/04 14:47:54 mj Exp $''' $Id: Tree.py,v 1.10 2002/10/04 16:50:58 mj Exp $'''
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
from Acquisition import Explicit from Acquisition import Explicit
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from types import ListType, TupleType
class TreeNode(Explicit): class TreeNode(Explicit):
__allow_access_to_unprotected_subobjects__ = 1 __allow_access_to_unprotected_subobjects__ = 1
...@@ -131,19 +132,22 @@ class TreeMaker: ...@@ -131,19 +132,22 @@ class TreeMaker:
def getChildren(self, object): def getChildren(self, object):
if self._values_function is not None: if self._values_function is not None:
return self._values_function(object) return self._values_function(object)
if self._values_filter and hasattr(object, 'aq_acquire'):
return object.aq_acquire(self._values, aqcallback, children = getattr(object, self._values)
self._values_filter)() if not (isinstance(children, ListType) or
return getattr(object, self._values)() 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, def simple_type(ob,
is_simple={type(''):1, type(0):1, type(0.0):1, is_simple={type(''):1, type(0):1, type(0.0):1,
type(0L):1, type(None):1 }.has_key): type(0L):1, type(None):1 }.has_key):
return is_simple(type(ob)) 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 binascii import b2a_base64, a2b_base64
from string import translate, maketrans from string import translate, maketrans
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment