Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
erp5
Commits
5e5a0998
Commit
5e5a0998
authored
May 09, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HBTreeFolder2: make sure _setOb does not overwrite a leaf at root tree
parent
7edac20b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
18 deletions
+12
-18
product/HBTreeFolder2/HBTreeFolder2.py
product/HBTreeFolder2/HBTreeFolder2.py
+10
-18
product/HBTreeFolder2/tests/testHBTreeFolder2.py
product/HBTreeFolder2/tests/testHBTreeFolder2.py
+2
-0
No files found.
product/HBTreeFolder2/HBTreeFolder2.py
View file @
5e5a0998
...
@@ -308,25 +308,17 @@ class HBTreeFolder2Base (Persistent):
...
@@ -308,25 +308,17 @@ class HBTreeFolder2Base (Persistent):
if
type
(
object
)
is
OOBTree
:
if
type
(
object
)
is
OOBTree
:
raise
ValueError
(
'HBTreeFolder2 can not store OOBTree objects'
)
raise
ValueError
(
'HBTreeFolder2 can not store OOBTree objects'
)
htree
=
self
.
_htree
htree
=
self
.
_htree
id_list
=
self
.
hashId
(
id
)
for
sub_id
in
self
.
hashId
(
id
)[:
-
1
]:
for
idx
in
xrange
(
len
(
id_list
)
-
1
):
try
:
sub_id
=
id_list
[
idx
]
htree
=
htree
[
sub_id
]
if
not
htree
.
has_key
(
sub_id
):
except
KeyError
:
# Create a new level
htree
[
sub_id
]
=
htree
=
OOBTree
()
htree
[
sub_id
]
=
OOBTree
()
continue
if
isinstance
(
sub_id
,
(
int
,
long
)):
if
type
(
htree
)
is
not
OOBTree
:
tree_id
=
0
assert
self
.
_htree
[
sub_id
]
is
htree
,
(
htree
,
id
)
for
id
in
id_list
[:
idx
+
1
]:
raise
KeyError
(
'There is already an item whose id is %r'
%
sub_id
)
tree_id
=
tree_id
+
id
*
MAX_OBJECT_PER_LEVEL
else
:
tree_id
=
H_SEPARATOR
.
join
(
id_list
[:
idx
+
1
])
htree
=
htree
[
sub_id
]
# set object in subtree
ob_id
=
id_list
[
-
1
]
if
htree
.
has_key
(
id
):
if
htree
.
has_key
(
id
):
raise
KeyError
(
'There is already an item named "%s"
.'
%
id
)
raise
KeyError
(
'There is already an item named %r
.'
%
id
)
htree
[
id
]
=
object
htree
[
id
]
=
object
self
.
_count
.
change
(
1
)
self
.
_count
.
change
(
1
)
...
...
product/HBTreeFolder2/tests/testHBTreeFolder2.py
View file @
5e5a0998
...
@@ -47,6 +47,8 @@ class HBTreeFolder2Tests(ERP5TypeTestCase):
...
@@ -47,6 +47,8 @@ class HBTreeFolder2Tests(ERP5TypeTestCase):
f
.
_setOb
(
id
,
ff
)
f
.
_setOb
(
id
,
ff
)
f
.
_getOb
(
id
)
f
.
_getOb
(
id
)
for
id
in
"a-a"
,
"b"
,
"c-a"
:
for
id
in
"a-a"
,
"b"
,
"c-a"
:
if
id
!=
"c-a"
:
self
.
assertRaises
(
KeyError
,
f
.
_setOb
,
id
,
ff
)
self
.
assertRaises
(
KeyError
,
f
.
_getOb
,
id
)
self
.
assertRaises
(
KeyError
,
f
.
_getOb
,
id
)
self
.
assertRaises
(
KeyError
,
f
.
_delOb
,
id
)
self
.
assertRaises
(
KeyError
,
f
.
_delOb
,
id
)
self
.
assertEqual
(
len
(
f
),
1
+
len
(
ok
))
self
.
assertEqual
(
len
(
f
),
1
+
len
(
ok
))
...
...
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