Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
f4a9629b
Commit
f4a9629b
authored
Jul 11, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added setChildAccess() method for setting up tree child node access.
parent
251876f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
lib/python/ZTUtils/Tree.py
lib/python/ZTUtils/Tree.py
+24
-2
No files found.
lib/python/ZTUtils/Tree.py
View file @
f4a9629b
...
...
@@ -84,8 +84,8 @@
##############################################################################
__doc__
=
'''Tree manipulation classes
$Id: Tree.py,v 1.
2 2001/04/27 20:51
:20 evan Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
$Id: Tree.py,v 1.
3 2001/07/11 16:23
:20 evan Exp $'''
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
from
Acquisition
import
Explicit
from
ComputedAttribute
import
ComputedAttribute
...
...
@@ -122,6 +122,8 @@ class TreeNode(Explicit):
return
self
.
_child_list
[
index
].
__of__
(
self
)
def
__len__
(
self
):
return
len
(
self
.
_child_list
)
_marker
=
[]
class
TreeMaker
:
'''Class for mapping a hierachy of objects into a tree of nodes.'''
...
...
@@ -132,7 +134,25 @@ class TreeMaker:
_values
=
'tpValues'
_assume_children
=
0
_values_filter
=
None
_values_function
=
None
_expand_root
=
1
def
setChildAccess
(
self
,
attrname
=
_marker
,
filter
=
_marker
,
function
=
_marker
):
'''Set the criteria for fetching child nodes.
Child nodes can be accessed through either an attribute name
or callback function. Children fetched by attribute name can
be filtered through a callback function.
'''
if
function
is
_marker
:
self
.
_values_function
=
None
if
attrname
is
not
_marker
:
self
.
_values
=
str
(
attrname
)
if
filter
is
not
_marker
:
self
.
_values_filter
=
filter
else
:
self
.
_values_function
=
function
def
tree
(
self
,
root
,
expanded
=
None
,
subtree
=
0
):
'''Create a tree from root, with specified nodes expanded.
...
...
@@ -183,6 +203,8 @@ class TreeMaker:
return
self
.
getChildren
(
object
)
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
)()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment