Commit f70e1e32 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Use Workflow.disable decorator rather than volatile.

Rewrite fb9ab20f as the volatile usage is
wrong as the object may be unloaded to save space (and thus workflows enabled)
before editDocument() is actually finished.
parent 85af32bd
...@@ -32,6 +32,7 @@ from Products.ERP5SyncML.XMLSyncUtils import getXupdateObject ...@@ -32,6 +32,7 @@ from Products.ERP5SyncML.XMLSyncUtils import getXupdateObject
from Products.ERP5Type.Utils import deprecated from Products.ERP5Type.Utils import deprecated
from Products.ERP5Type.XMLExportImport import MARSHALLER_NAMESPACE_URI from Products.ERP5Type.XMLExportImport import MARSHALLER_NAMESPACE_URI
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Base import WorkflowMethod
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from email.mime.base import MIMEBase from email.mime.base import MIMEBase
from email import encoders from email import encoders
...@@ -979,16 +980,20 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -979,16 +980,20 @@ class ERP5Conduit(XMLSyncUtilsMixin):
return conflict_list return conflict_list
security.declareProtected(Permissions.ModifyPortalContent, 'editDocument') security.declareProtected(Permissions.ModifyPortalContent, 'editDocument')
# XXX Ugly hack to avoid calling interaction workflow when synchronizing
# objects with ERP5SyncML as it leads to unwanted side-effects on the object
# being synchronized, such as undesirable workflow history being added (for
# example edit_workflow) and double conversion for OOo documents (for
# example document_conversion_interaction_workflow defined for _setData())
# making the source and destination XML representation different.
@WorkflowMethod.disable
def editDocument(self, object=None, **kw): def editDocument(self, object=None, **kw):
""" """
This is the default editDocument method. This method This is the default editDocument method. This method
can easily be overwritten. can easily be overwritten.
""" """
object._v_inhibit_workflow = True object._edit(**kw)
try:
object._edit(**kw)
finally:
object._v_inhibit_workflow = False
security.declareProtected(Permissions.ModifyPortalContent, 'getProperty') security.declareProtected(Permissions.ModifyPortalContent, 'getProperty')
def getProperty(self, object, kw): def getProperty(self, object, kw):
......
...@@ -174,16 +174,6 @@ class WorkflowMethod(Method): ...@@ -174,16 +174,6 @@ class WorkflowMethod(Method):
# XXX I must think that what is a correct behavior.(Yusei) # XXX I must think that what is a correct behavior.(Yusei)
return self._m(instance, *args, **kw) return self._m(instance, *args, **kw)
# XXX Ugly hack to avoid calling interaction workflow when synchronizing
# objects with ERP5SyncML as it leads to unwanted side-effects on the
# object being synchronized, such as undesirable workflow history being
# added (for example edit_workflow) and double conversion for OOo
# documents (for example document_conversion_interaction_workflow defined
# for _setData()) making the source and destination XML representation
# different.
if getattr(instance, '_v_inhibit_workflow', False):
return apply(self.__dict__['_m'], (instance,) + args, kw)
# Build a list of transitions which may need to be invoked # Build a list of transitions which may need to be invoked
instance_path = instance.getPhysicalPath() instance_path = instance.getPhysicalPath()
portal_type = instance.portal_type portal_type = instance.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