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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
erp5
Commits
5a71ba9b
Commit
5a71ba9b
authored
Dec 22, 2017
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_interface_post: improve allow_export's after-actions to be race-condition proof
parent
0523b99b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
6 deletions
+35
-6
bt5/erp5_interface_post/SkinTemplateItem/portal_skins/erp5_interface_post/InterfacePost_disallowExportOfSameInterfacePostListAndExport.py
...acePost_disallowExportOfSameInterfacePostListAndExport.py
+30
-0
bt5/erp5_interface_post/SkinTemplateItem/portal_skins/erp5_interface_post/InterfacePost_disallowExportOfSameInterfacePostListAndExport.xml
...cePost_disallowExportOfSameInterfacePostListAndExport.xml
+1
-1
bt5/erp5_interface_post/WorkflowTemplateItem/portal_workflow/interface_post_workflow/scripts/afterAllowExport.py
...kflow/interface_post_workflow/scripts/afterAllowExport.py
+4
-5
No files found.
bt5/erp5_interface_post/SkinTemplateItem/portal_skins/erp5_interface_post/InterfacePost_disallowExportOfSameInterfacePostList.py
→
bt5/erp5_interface_post/SkinTemplateItem/portal_skins/erp5_interface_post/InterfacePost_disallowExportOfSameInterfacePostList
AndExport
.py
View file @
5a71ba9b
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
# Because this script can be called at the ~ same time on different
# posts, it can raise race conditions where several posts disallow
# export of each other, resulting in nothing is exported. Checking
# the current state of the post here prevents a post which has
# already been disallowed to disallow the post which disalowed it.
# 2 Posts can still be exported at same time if one isn't indexed
# correctly yet.
if
context
.
getSimulationState
()
!=
'exportable'
:
return
# 1/ Disallow export of posts for the same origin message
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
module
=
context
.
getParentValue
()
module
=
context
.
getParentValue
()
...
@@ -13,3 +25,6 @@ exportable_post_list = portal.portal_catalog(
...
@@ -13,3 +25,6 @@ exportable_post_list = portal.portal_catalog(
for
exportable_post
in
exportable_post_list
:
for
exportable_post
in
exportable_post_list
:
exportable_post
.
disallowExport
()
exportable_post
.
disallowExport
()
# 2/ Export post
context
.
InterfacePost_exportAfterAllowExport
()
bt5/erp5_interface_post/SkinTemplateItem/portal_skins/erp5_interface_post/InterfacePost_disallowExportOfSameInterfacePostList.xml
→
bt5/erp5_interface_post/SkinTemplateItem/portal_skins/erp5_interface_post/InterfacePost_disallowExportOfSameInterfacePostList
AndExport
.xml
View file @
5a71ba9b
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
InterfacePost_disallowExportOfSameInterfacePostList
</string>
</value>
<value>
<string>
InterfacePost_disallowExportOfSameInterfacePostList
AndExport
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
bt5/erp5_interface_post/WorkflowTemplateItem/portal_workflow/interface_post_workflow/scripts/afterAllowExport.py
View file @
5a71ba9b
post
=
state_change
[
'object'
]
post
=
state_change
[
'object'
]
post
.
activate
(
tag
=
'interface_post_disallow_export'
)
\
# Priority 2 is just enough to be executed after the immediateReindexObject
.
InterfacePost_disallowExportOfSameInterfacePostList
()
post
.
activate
(
serialization_tag
=
'export_interface_post'
,
priority
=
2
)
\
post
.
activate
(
after_tag
=
'interface_post_disallow_export'
)
\
.
InterfacePost_disallowExportOfSameInterfacePostListAndExport
()
.
InterfacePost_exportAfterAllowExport
()
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