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
aa2ca37e
Commit
aa2ca37e
authored
Nov 10, 1997
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added expand=... functionality
parent
229b5573
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
47 deletions
+84
-47
lib/python/TreeDisplay/TreeTag.py
lib/python/TreeDisplay/TreeTag.py
+84
-47
No files found.
lib/python/TreeDisplay/TreeTag.py
View file @
aa2ca37e
...
...
@@ -9,8 +9,8 @@
# rights reserved.
#
############################################################################
__rcs_id__
=
'$Id: TreeTag.py,v 1.
5 1997/09/09 23:17:25 brian
Exp $'
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: TreeTag.py,v 1.
6 1997/11/10 16:32:48 jeffrey
Exp $'
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_String
import
String
...
...
@@ -18,19 +18,24 @@ from DocumentTemplate.DT_String import String
class
Tree
:
name
=
'tree'
blockContinuations
=
()
expand
=
None
def
__init__
(
self
,
blocks
):
tname
,
args
,
section
=
blocks
[
0
]
args
=
parse_params
(
args
,
name
=
''
)
args
=
parse_params
(
args
,
name
=
''
,
expand
=
''
)
name
=
name_param
(
args
)
self
.
__name__
=
name
self
.
section
=
section
if
args
.
has_key
(
'expand'
)
and
args
[
'expand'
]:
self
.
expand
=
args
[
'expand'
]
def
render
(
self
,
md
):
try
:
v
=
md
[
self
.
__name__
]
except
:
v
=
None
if
v
is
None
:
return
''
return
tpRender
(
v
,
md
,
self
.
section
)
expand
=
self
.
expand
if
expand
:
expand
=
md
.
getitem
(
expand
,
0
)
return
tpRender
(
v
,
md
,
self
.
section
,
expand
)
__call__
=
render
...
...
@@ -42,51 +47,66 @@ from urllib import quote, unquote
pyid
=
id
# Copy builtin
def
tpRender
(
self
,
md
,
section
):
# Check for collapse all, expand all, and state
try
:
collapse_all
=
md
[
'collapse_all'
]
except
:
collapse_all
=
None
if
collapse_all
:
state
=
[]
else
:
try
:
expand_all
=
md
[
'expand_all'
]
except
:
expand_all
=
None
if
expand_all
:
state
=
tpValuesIds
(
self
)
def
tpRender
(
self
,
md
,
section
,
expand
):
data
=
[]
try
:
# see if we are being run as a sub-document
root
=
md
[
'tree-root-url'
]
url
=
md
[
'tree-item-url'
]
state
=
md
[
'tree-state'
]
or
md
[
'state'
]
substate
=
md
[
'-tree-substate-'
]
colspan
=
md
[
'tree-colspan'
]
level
=
md
[
'tree-level'
]
except
KeyError
:
# Check for collapse all, expand all, and state
try
:
collapse_all
=
md
[
'collapse_all'
]
except
:
collapse_all
=
None
if
collapse_all
:
state
=
[]
else
:
try
:
state
=
md
[
'state'
]
if
state
[
0
]
!=
'['
:
state
=
unquote
(
state
)
state
=
list
(
eval
(
state
,{
'__builtins__'
:{}}))
except
:
state
=
[]
try
:
expand_all
=
md
[
'expand_all'
]
except
:
expand_all
=
None
if
expand_all
:
state
=
tpValuesIds
(
self
)
else
:
try
:
state
=
md
[
'tree-state'
]
or
md
[
'state'
]
or
md
[
'-tree-state-'
]
if
state
[
0
]
!=
'['
:
state
=
unquote
(
state
)
state
=
list
(
eval
(
state
,{
'__builtins__'
:{}}))
except
:
state
=
[]
colspan
=
1
+
tpStateLevel
(
state
)
level
=
0
substate
=
state
root
=
md
[
'URL'
]
l
=
rfind
(
root
,
'/'
)
if
l
>=
0
:
root
=
root
[
l
+
1
:]
url
=
''
# Save state in a cookie
if
state
:
md
[
'RESPONSE'
].
setCookie
(
'state'
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
))
else
:
md
[
'RESPONSE'
].
expireCookie
(
'state'
)
if
state
:
md
[
'RESPONSE'
].
setCookie
(
'tree-state'
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
))
else
:
md
[
'RESPONSE'
].
expireCookie
(
'tree-state'
)
if
substate
==
state
:
data
.
append
(
'<TABLE CELLSPACING="0">
\
n
'
)
#level=0
treeData
=
{
'tree-root-url'
:
root
,
'tree-colspan'
:
colspan
,
'tree-state'
:
state
}
root
=
md
[
'URL'
]
l
=
rfind
(
root
,
'/'
)
if
l
>=
0
:
root
=
root
[
l
+
1
:]
url
=
''
data
=
[]
data
.
append
(
'<TABLE CELLSPACING="0">
\
n
'
)
colspan
=
1
+
tpStateLevel
(
state
)
treeData
=
{
'tree-root-url'
:
root
}
md
.
push
(
treeData
)
try
:
for
item
in
self
.
tpValues
():
data
=
tpRenderTABLE
(
item
,
root
,
url
,
state
,
state
,
data
,
colspan
,
section
,
md
,
treeData
)
data
.
append
(
'</TABLE>
\
n
'
)
data
=
tpRenderTABLE
(
item
,
root
,
url
,
state
,
s
ubs
tate
,
data
,
colspan
,
section
,
md
,
treeData
,
level
,
expand
)
if
state
is
substate
:
data
.
append
(
'</TABLE>
\
n
'
)
result
=
join
(
data
,
''
)
finally
:
md
.
pop
(
1
)
return
result
def
tpStateLevel
(
state
):
level
=
0
def
tpStateLevel
(
state
,
level
=
0
):
for
sub
in
state
:
if
len
(
sub
)
==
2
:
level
=
max
(
level
,
1
+
tpStateLevel
(
sub
[
1
]))
else
:
level
=
max
(
level
,
1
)
...
...
@@ -112,16 +132,16 @@ def tpValuesIds(self):
def
tpRenderTABLE
(
self
,
root_url
,
url
,
state
,
substate
,
data
,
colspan
,
section
,
md
,
treeData
,
level
=
0
):
colspan
,
section
,
md
,
treeData
,
level
=
0
,
expand
=
None
):
try
:
items
=
self
.
tpValues
()
except
:
items
=
None
tpUrl
=
self
.
tpURL
()
url
=
(
url
and
(
'%s/%s'
%
(
url
,
tpUrl
)))
or
tpUrl
treeData
[
'tree-item-url'
]
=
url
treeData
[
'tree-level'
]
=
level
treeData
[
'tree-item-expanded'
]
=
0
try
:
id
=
self
.
tpId
()
except
:
id
=
None
if
id
is
None
:
...
...
@@ -148,12 +168,12 @@ def tpRenderTABLE(self, root_url, url, state, substate, data,
if
exp
:
treeData
[
'tree-item-expanded'
]
=
1
del
substate
[
exp
-
1
]
output
(
'<A HREF="%s?state=%s">%s</A>'
%
output
(
'<A HREF="%s?
tree-
state=%s">%s</A>'
%
(
root_url
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
),
icoMinus
))
substate
.
append
(
sub
)
else
:
substate
.
append
([
id
])
output
(
'<A HREF="%s?state=%s">%s</A>'
%
output
(
'<A HREF="%s?
tree-
state=%s">%s</A>'
%
(
root_url
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
),
icoPlus
))
del
substate
[
-
1
]
else
:
...
...
@@ -166,11 +186,18 @@ def tpRenderTABLE(self, root_url, url, state, substate, data,
output
(
'</TD>
\
n
</TR>
\
n
'
)
if
exp
:
for
item
in
items
:
if
len
(
sub
)
==
1
:
sub
.
append
([])
data
=
tpRenderTABLE
(
item
,
root_url
,
url
,
state
,
sub
[
1
],
data
,
colspan
,
section
,
md
,
treeData
,
level
+
1
)
if
not
sub
[
1
]:
del
sub
[
1
]
if
expand
is
not
None
:
treeData
[
'-tree-substate-'
]
=
sub
treeData
[
'tree-level'
]
=
level
+
1
md
.
push
(
treeData
)
output
(
expand
(
self
,
md
))
md
.
pop
(
1
)
else
:
for
item
in
items
:
if
len
(
sub
)
==
1
:
sub
.
append
([])
data
=
tpRenderTABLE
(
item
,
root_url
,
url
,
state
,
sub
[
1
],
data
,
colspan
,
section
,
md
,
treeData
,
level
+
1
)
if
not
sub
[
1
]:
del
sub
[
1
]
return
data
...
...
@@ -178,3 +205,13 @@ icoSpace='<IMG SRC="%s/TreeDisplay/Blank_icon.gif" BORDER="0">' % SOFTWARE_URL
icoPlus
=
'<IMG SRC="%s/TreeDisplay/Plus_icon.gif" BORDER="0">'
%
SOFTWARE_URL
icoMinus
=
'<IMG SRC="%s/TreeDisplay/Minus_icon.gif" BORDER="0">'
%
SOFTWARE_URL
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