Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
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
Romain Courteaud
erp5_rtl_support
Commits
637bb55b
Commit
637bb55b
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
2b41e7ce
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 @
637bb55b
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
()
module
=
context
.
getParentValue
()
...
...
@@ -13,3 +25,6 @@ exportable_post_list = portal.portal_catalog(
for
exportable_post
in
exportable_post_list
:
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 @
637bb55b
...
...
@@ -54,7 +54,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
InterfacePost_disallowExportOfSameInterfacePostList
</string>
</value>
<value>
<string>
InterfacePost_disallowExportOfSameInterfacePostList
AndExport
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
bt5/erp5_interface_post/WorkflowTemplateItem/portal_workflow/interface_post_workflow/scripts/afterAllowExport.py
View file @
637bb55b
post
=
state_change
[
'object'
]
post
.
activate
(
tag
=
'interface_post_disallow_export'
)
\
.
InterfacePost_disallowExportOfSameInterfacePostList
()
post
.
activate
(
after_tag
=
'interface_post_disallow_export'
)
\
.
InterfacePost_exportAfterAllowExport
()
# Priority 2 is just enough to be executed after the immediateReindexObject
post
.
activate
(
serialization_tag
=
'export_interface_post'
,
priority
=
2
)
\
.
InterfacePost_disallowExportOfSameInterfacePostListAndExport
()
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