Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
Commits
c642f693
Commit
c642f693
authored
May 23, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
websection: Do not accumulate websection traveral hook when copy pasting
Also cleanup existing documents
parent
f175a3b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
product/ERP5/Document/WebSection.py
product/ERP5/Document/WebSection.py
+23
-4
No files found.
product/ERP5/Document/WebSection.py
View file @
c642f693
...
...
@@ -151,6 +151,21 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
BeforeTraverse
.
registerBeforeTraverse
(
item
,
WebSectionTraversalHook
(),
handle
)
super
(
WebSection
,
self
).
manage_afterAdd
(
item
,
container
)
security
.
declarePrivate
(
'manage_afterClone'
)
def
manage_afterClone
(
self
,
item
):
self
.
_cleanupBeforeTraverseHooks
()
super
(
WebSection
,
self
).
manage_afterClone
(
item
)
def
_cleanupBeforeTraverseHooks
(
self
):
# unregister all before traversal hooks that do not belong to us.
my_handle
=
self
.
meta_type
+
'/'
+
self
.
getId
()
handle_to_unregister_list
=
[]
for
(
priority
,
handle
),
hook
in
self
.
__before_traverse__
.
items
():
if
isinstance
(
hook
,
WebSectionTraversalHook
)
and
handle
!=
my_handle
:
handle_to_unregister_list
.
append
(
handle
)
for
handle
in
handle_to_unregister_list
:
BeforeTraverse
.
unregisterBeforeTraverse
(
self
,
handle
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getLayoutProperty'
)
def
getLayoutProperty
(
self
,
key
,
default
=
None
):
"""
...
...
@@ -427,8 +442,12 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
return
result
def
_edit
(
self
,
**
kw
):
# migrate beforeTraverse hook if missing
if
getattr
(
self
,
'__before_traverse__'
,
None
)
is
None
and
self
.
getPortalType
()
==
'Web Section'
:
handle
=
self
.
meta_type
+
'/'
+
self
.
getId
()
BeforeTraverse
.
registerBeforeTraverse
(
self
,
WebSectionTraversalHook
(),
handle
)
if
self
.
getPortalType
()
==
'Web Section'
:
if
getattr
(
self
,
'__before_traverse__'
,
None
)
is
None
:
# migrate beforeTraverse hook if missing
handle
=
self
.
meta_type
+
'/'
+
self
.
getId
()
BeforeTraverse
.
registerBeforeTraverse
(
self
,
WebSectionTraversalHook
(),
handle
)
else
:
# cleanup beforeTraverse hooks that may exist after this document was cloned.
self
.
_cleanupBeforeTraverseHooks
()
super
(
WebSection
,
self
).
_edit
(
**
kw
)
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