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
4857a055
Commit
4857a055
authored
Sep 09, 1997
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed cookie support in TreeTag
parent
6f4defc5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
52 deletions
+38
-52
lib/python/TreeDisplay/TreeTag.py
lib/python/TreeDisplay/TreeTag.py
+38
-52
No files found.
lib/python/TreeDisplay/TreeTag.py
View file @
4857a055
...
...
@@ -9,8 +9,8 @@
# rights reserved.
#
############################################################################
__rcs_id__
=
'$Id: TreeTag.py,v 1.
4 1997/09/09 23:09:03
brian Exp $'
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__rcs_id__
=
'$Id: TreeTag.py,v 1.
5 1997/09/09 23:17:25
brian Exp $'
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_String
import
String
...
...
@@ -41,43 +41,37 @@ from urllib import quote, unquote
pyid
=
id
# Copy builtin
# Generified example of tree support a la discussion...
def
tpRender
(
self
,
md
,
section
):
# Check for collapse all, expand all, and state
try
:
collapse_all
=
md
[
'collapse_all'
]
try
:
collapse_all
=
md
[
'collapse_all'
]
except
:
collapse_all
=
None
if
collapse_all
:
state
=
[]
else
:
try
:
expand_all
=
md
[
'expand_all'
]
try
:
expand_all
=
md
[
'expand_all'
]
except
:
expand_all
=
None
if
expand_all
:
# in case of expand all - to maintain state correctly we
# have to make state be the ids of ALL subobjects which
# are non-empty (recursively).
state
=
tpValuesIds
(
self
)
else
:
try
:
state
=
md
[
'state'
]
if
state
[
0
]
!=
'['
:
state
=
unquote
(
state
)
state
=
list
(
eval
(
state
,{
'__builtins__'
:{}}))
except
:
state
=
[]
# Try to save state in a cookie as well...
# md['RESPONSE'].setCookie('state',state)
except
:
state
=
[]
# Save state in a cookie
if
state
:
md
[
'RESPONSE'
].
setCookie
(
'state'
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
))
else
:
md
[
'RESPONSE'
].
expireCookie
(
'state'
)
root
=
md
[
'URL'
]
l
=
rfind
(
root
,
'/'
)
if
l
>=
0
:
root
=
root
[
l
+
1
:]
url
=
''
data
=
[]
data
.
append
(
'<
table cellspacing=0
>
\
n
'
)
data
.
append
(
'<
TABLE CELLSPACING="0"
>
\
n
'
)
colspan
=
1
+
tpStateLevel
(
state
)
treeData
=
{
'tree-root-url'
:
root
}
...
...
@@ -86,12 +80,9 @@ def tpRender(self, md, section):
for
item
in
self
.
tpValues
():
data
=
tpRenderTABLE
(
item
,
root
,
url
,
state
,
state
,
data
,
colspan
,
section
,
md
,
treeData
)
data
.
append
(
'</table>
\
n
'
)
data
.
append
(
'</TABLE>
\
n
'
)
result
=
join
(
data
,
''
)
finally
:
md
.
pop
(
1
)
return
result
def
tpStateLevel
(
state
):
...
...
@@ -102,15 +93,19 @@ def tpStateLevel(state):
return
level
def
tpValuesIds
(
self
):
# This should build the ids of subitems which are
# expandable (non-empty). Leaves should never be
# in the state - it will screw the colspan counting.
r
=
[]
try
:
for
item
in
self
.
tpValues
():
try
:
id
=
item
.
tpId
()
e
=
tpValuesIds
(
item
)
if
e
:
id
=
[
id
,
e
]
else
:
id
=
[
id
]
r
.
append
(
id
)
if
item
.
tpValues
():
id
=
item
.
tpId
()
e
=
tpValuesIds
(
item
)
if
e
:
id
=
[
id
,
e
]
else
:
id
=
[
id
]
r
.
append
(
id
)
except
:
pass
except
:
pass
return
r
...
...
@@ -118,20 +113,19 @@ def tpValuesIds(self):
def
tpRenderTABLE
(
self
,
root_url
,
url
,
state
,
substate
,
data
,
colspan
,
section
,
md
,
treeData
,
level
=
0
):
# We are being called from above
try
:
items
=
self
.
tpValues
()
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-item-expanded'
]
=
0
try
:
id
=
self
.
tpId
()
try
:
id
=
self
.
tpId
()
except
:
id
=
None
if
id
is
None
:
try
:
id
=
self
.
_p_oid
try
:
id
=
self
.
_p_oid
except
:
id
=
None
if
id
is
None
:
id
=
pyid
(
self
)
...
...
@@ -140,20 +134,19 @@ def tpRenderTABLE(self, root_url, url, state, substate, data,
output
=
data
.
append
# Add prefix
output
(
'<
tr>
'
)
if
level
:
output
(
'<
td></td>
'
*
level
)
output
(
'<
TR>
\
n
'
)
if
level
:
output
(
'<
TD WIDTH="16"></TD>
\
n
'
*
level
)
# Add
tree expand/contract
icon
# Add
+/-
icon
if
items
:
output
(
'<td valign=top>'
)
output
(
'<TD WIDTH="16" VALIGN="TOP">'
)
for
i
in
range
(
len
(
substate
)):
sub
=
substate
[
i
]
if
sub
[
0
]
==
id
:
exp
=
i
+
1
break
if
exp
:
treeData
[
'tree-item-expanded'
]
=
1
del
substate
[
exp
-
1
]
output
(
'<A HREF="%s?state=%s">%s</A>'
%
(
root_url
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
),
icoMinus
))
...
...
@@ -164,14 +157,13 @@ def tpRenderTABLE(self, root_url, url, state, substate, data,
(
root_url
,
quote
(
str
(
state
)[
1
:
-
1
]
+
','
),
icoPlus
))
del
substate
[
-
1
]
else
:
output
(
'<td>'
)
output
(
'</td>
\
n
'
)
output
(
'<TD WIDTH="16">'
)
output
(
'</TD>
\
n
'
)
# add item text
output
(
'<
td colspan=%s valign=top>'
%
colspan
)
output
(
'<
TD COLSPAN="%s" VALIGN="TOP">'
%
(
colspan
-
level
)
)
output
(
section
(
self
,
md
))
output
(
'</
td></tr
>
\
n
'
)
output
(
'</
TD>
\
n
</TR
>
\
n
'
)
if
exp
:
for
item
in
items
:
...
...
@@ -179,16 +171,10 @@ def tpRenderTABLE(self, root_url, url, state, substate, data,
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
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
icoSpace
=
'<IMG SRC="%s/TreeDisplay/Blank_icon.gif" '
\
' BORDER="0">'
%
SOFTWARE_URL
icoPlus
=
'<IMG SRC="%s/TreeDisplay/Plus_icon.gif" BORDER="0"'
\
' ALT="+">'
%
SOFTWARE_URL
icoMinus
=
'<IMG SRC="%s/TreeDisplay/Minus_icon.gif" BORDER="0"'
\
' ALT="-">'
%
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