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
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
Eteri
erp5
Commits
30b9d5b1
Commit
30b9d5b1
authored
May 09, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HBTreeFolder2: automatic prune trees that become empty after that an object is deleted
parent
7c085c43
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
product/HBTreeFolder2/HBTreeFolder2.py
product/HBTreeFolder2/HBTreeFolder2.py
+5
-0
product/HBTreeFolder2/tests/testHBTreeFolder2.py
product/HBTreeFolder2/tests/testHBTreeFolder2.py
+2
-0
No files found.
product/HBTreeFolder2/HBTreeFolder2.py
View file @
30b9d5b1
...
...
@@ -322,7 +322,9 @@ class HBTreeFolder2Base (Persistent):
"""Remove the named object from the folder.
"""
htree
=
self
.
_htree
h
=
[]
for
sub_id
in
self
.
hashId
(
id
)[:
-
1
]:
h
.
append
((
htree
,
sub_id
))
htree
=
htree
.
get
(
sub_id
)
if
type
(
htree
)
is
not
OOBTree
:
raise
KeyError
(
id
)
...
...
@@ -330,6 +332,9 @@ class HBTreeFolder2Base (Persistent):
raise
KeyError
(
id
)
del
htree
[
id
]
self
.
_count
.
change
(
-
1
)
while
h
and
not
htree
:
htree
,
sub_id
=
h
.
pop
()
del
htree
[
sub_id
]
security
.
declareProtected
(
view_management_screens
,
'getBatchObjectListing'
)
def
getBatchObjectListing
(
self
,
REQUEST
=
None
):
...
...
product/HBTreeFolder2/tests/testHBTreeFolder2.py
View file @
30b9d5b1
...
...
@@ -53,8 +53,10 @@ class HBTreeFolder2Tests(ERP5TypeTestCase):
self
.
assertRaises
(
KeyError
,
f
.
_delOb
,
id
)
self
.
assertEqual
(
len
(
f
),
1
+
len
(
ok
))
self
.
assertEqual
(
f
.
getTreeIdList
(),
[
None
,
"b"
,
"c-a"
])
self
.
assertEqual
(
len
(
f
.
_htree
),
4
)
for
id
in
ok
:
f
.
_delOb
(
id
)
self
.
assertEqual
(
len
(
f
.
_htree
),
1
)
self
.
assertEqual
(
len
(
f
),
1
)
self
.
assertEqual
(
f
.
getTreeIdList
(),
[
None
])
self
.
assertEqual
(
ff
.
getTreeIdList
(),
[])
...
...
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