Commit aa3a313d authored by Julien Muchembled's avatar Julien Muchembled

New serialise...State accessor

This will be required to fix a possible race condition in causality_workflow
parent c2e4e557
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# #
############################################################################## ##############################################################################
from Acquisition import aq_base
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
from Base import Getter as BaseGetter, Setter as BaseSetter from Base import Getter as BaseGetter, Setter as BaseSetter
from warnings import warn from warnings import warn
...@@ -120,3 +121,16 @@ class TranslatedTitleGetter(TitleGetter): ...@@ -120,3 +121,16 @@ class TranslatedTitleGetter(TitleGetter):
return result.encode('utf8') return result.encode('utf8')
psyco.bind(__call__) psyco.bind(__call__)
def SerializeGetter(id, key):
def serialize(self):
"""Prevent concurrent transaction from changing of state of this object
"""
try:
self = aq_base(self).workflow_history
self = self[key]
except (AttributeError, KeyError):
pass
self._p_changed = 1
serialize.__name__ = id
return serialize
...@@ -518,7 +518,9 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow): ...@@ -518,7 +518,9 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
('getTranslated%s' % UpperCase(state_var), ('getTranslated%s' % UpperCase(state_var),
WorkflowState.TranslatedGetter), WorkflowState.TranslatedGetter),
('getTranslated%sTitle' % UpperCase(state_var), ('getTranslated%sTitle' % UpperCase(state_var),
WorkflowState.TranslatedTitleGetter)): WorkflowState.TranslatedTitleGetter),
('serialize%s' % UpperCase(state_var), WorkflowState.SerializeGetter),
):
if not hasattr(ptype_klass, method_id): if not hasattr(ptype_klass, method_id):
method = getter(method_id, wf_id) method = getter(method_id, wf_id)
# Attach to portal_type # Attach to portal_type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment