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
fc582b40
Commit
fc582b40
authored
Dec 11, 2003
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #1133: TreeTag choked on Ids of type long.
parent
a6fe70ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
doc/CHANGES.txt
doc/CHANGES.txt
+2
-0
lib/python/TreeDisplay/TreeTag.py
lib/python/TreeDisplay/TreeTag.py
+21
-13
No files found.
doc/CHANGES.txt
View file @
fc582b40
...
@@ -82,6 +82,8 @@ Zope Changes
...
@@ -82,6 +82,8 @@ Zope Changes
Bugs fixed
Bugs fixed
- Collector #1133: TreeTag choked on Ids of type long.
- Collector #1012: A carefully crafted compressed tree state
- Collector #1012: A carefully crafted compressed tree state
could violate size limit. Limit is no longer hardcoded.
could violate size limit. Limit is no longer hardcoded.
...
...
lib/python/TreeDisplay/TreeTag.py
View file @
fc582b40
...
@@ -12,8 +12,8 @@
...
@@ -12,8 +12,8 @@
##############################################################################
##############################################################################
"""Rendering object hierarchies as Trees
"""Rendering object hierarchies as Trees
"""
"""
__rcs_id__
=
'$Id: TreeTag.py,v 1.5
5 2003/11/18 13:17:14 tseaver
Exp $'
__rcs_id__
=
'$Id: TreeTag.py,v 1.5
6 2003/12/11 22:49:17 evan
Exp $'
__version__
=
'$Revision: 1.5
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_Util
import
*
from
DocumentTemplate.DT_String
import
String
from
DocumentTemplate.DT_String
import
String
...
@@ -92,8 +92,20 @@ String.commands['tree']=Tree
...
@@ -92,8 +92,20 @@ String.commands['tree']=Tree
pyid
=
id
# Copy builtin
pyid
=
id
# Copy builtin
simple_types
=
{
str
:
1
,
unicode
:
1
,
int
:
1
,
float
:
1
,
long
:
1
,
tuple
:
1
,
list
:
1
,
dict
:
1
}
def
try_call_attr
(
ob
,
attrname
,
simple_types
=
simple_types
):
attr
=
getattr
(
ob
,
attrname
)
if
type
(
attr
)
in
simple_types
:
return
attr
try
:
return
attr
()
except
TypeError
:
return
attr
def
tpRender
(
self
,
md
,
section
,
args
,
def
tpRender
(
self
,
md
,
section
,
args
,
simple_type
=
{
type
(
''
):
0
,
type
(
1
):
0
,
type
(
1.0
):
0
}.
has_key
):
try_call_attr
=
try_call_attr
):
"""Render data organized as a tree.
"""Render data organized as a tree.
We keep track of open nodes using a cookie. The cookie stored the
We keep track of open nodes using a cookie. The cookie stored the
...
@@ -118,8 +130,7 @@ def tpRender(self, md, section, args,
...
@@ -118,8 +130,7 @@ def tpRender(self, md, section, args,
idattr
=
args
[
'id'
]
idattr
=
args
[
'id'
]
if
hasattr
(
self
,
idattr
):
if
hasattr
(
self
,
idattr
):
id
=
getattr
(
self
,
idattr
)
id
=
try_call_attr
(
self
,
idattr
)
if
not
simple_type
(
type
(
id
)):
id
=
id
()
elif
hasattr
(
self
,
'_p_oid'
):
id
=
oid
(
self
)
elif
hasattr
(
self
,
'_p_oid'
):
id
=
oid
(
self
)
else
:
id
=
pyid
(
self
)
else
:
id
=
pyid
(
self
)
...
@@ -206,7 +217,7 @@ def tpRender(self, md, section, args,
...
@@ -206,7 +217,7 @@ def tpRender(self, md, section, args,
def
tpRenderTABLE
(
self
,
id
,
root_url
,
url
,
state
,
substate
,
diff
,
data
,
def
tpRenderTABLE
(
self
,
id
,
root_url
,
url
,
state
,
substate
,
diff
,
data
,
colspan
,
section
,
md
,
treeData
,
level
=
0
,
args
=
None
,
colspan
,
section
,
md
,
treeData
,
level
=
0
,
args
=
None
,
simple_type
=
{
type
(
''
):
0
,
type
(
1
):
0
,
type
(
1.0
):
0
}.
has_key
,
try_call_attr
=
try_call_attr
,
):
):
"Render a tree as a table"
"Render a tree as a table"
...
@@ -216,8 +227,7 @@ def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data,
...
@@ -216,8 +227,7 @@ def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data,
if
level
>=
0
:
if
level
>=
0
:
urlattr
=
args
[
'url'
]
urlattr
=
args
[
'url'
]
if
urlattr
and
hasattr
(
self
,
urlattr
):
if
urlattr
and
hasattr
(
self
,
urlattr
):
tpUrl
=
getattr
(
self
,
urlattr
)
tpUrl
=
try_call_attr
(
self
,
urlattr
)
if
not
simple_type
(
type
(
tpUrl
)):
tpUrl
=
tpUrl
()
url
=
(
url
and
(
'%s/%s'
%
(
url
,
tpUrl
)))
or
tpUrl
url
=
(
url
and
(
'%s/%s'
%
(
url
,
tpUrl
)))
or
tpUrl
root_url
=
root_url
or
tpUrl
root_url
=
root_url
or
tpUrl
...
@@ -438,8 +448,7 @@ def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data,
...
@@ -438,8 +448,7 @@ def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data,
ids
=
{}
ids
=
{}
for
item
in
items
:
for
item
in
items
:
if
hasattr
(
item
,
idattr
):
if
hasattr
(
item
,
idattr
):
id
=
getattr
(
item
,
idattr
)
id
=
try_call_attr
(
item
,
idattr
)
if
not
simple_type
(
type
(
id
)):
id
=
id
()
elif
hasattr
(
item
,
'_p_oid'
):
id
=
oid
(
item
)
elif
hasattr
(
item
,
'_p_oid'
):
id
=
oid
(
item
)
else
:
id
=
pyid
(
item
)
else
:
id
=
pyid
(
item
)
if
len
(
sub
)
==
1
:
sub
.
append
([])
if
len
(
sub
)
==
1
:
sub
.
append
([])
...
@@ -586,7 +595,7 @@ def tpStateLevel(state, level=0):
...
@@ -586,7 +595,7 @@ def tpStateLevel(state, level=0):
return
level
return
level
def
tpValuesIds
(
self
,
get_items
,
args
,
def
tpValuesIds
(
self
,
get_items
,
args
,
simple_type
=
{
type
(
''
):
0
,
type
(
1
):
0
,
type
(
1.0
):
0
}.
has_key
,
try_call_attr
=
try_call_attr
,
):
):
# get_item(node) is a function that returns the subitems of node
# get_item(node) is a function that returns the subitems of node
...
@@ -603,8 +612,7 @@ def tpValuesIds(self, get_items, args,
...
@@ -603,8 +612,7 @@ def tpValuesIds(self, get_items, args,
if
get_items
(
item
):
if
get_items
(
item
):
if
hasattr
(
item
,
idattr
):
if
hasattr
(
item
,
idattr
):
id
=
getattr
(
item
,
idattr
)
id
=
try_call_attr
(
item
,
idattr
)
if
not
simple_type
(
type
(
id
)):
id
=
id
()
elif
hasattr
(
item
,
'_p_oid'
):
id
=
oid
(
item
)
elif
hasattr
(
item
,
'_p_oid'
):
id
=
oid
(
item
)
else
:
id
=
pyid
(
item
)
else
:
id
=
pyid
(
item
)
...
...
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