From 12f5f171f2a85319539024f88421126a5c6e6e13 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Fri, 27 Feb 2004 12:28:26 +0000 Subject: [PATCH] edit object in a separate method git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@523 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5SyncML/Conduit/ERP5Conduit.py | 14 ++++++++++++-- product/ERP5SyncML/SynchronizationTool.py | 18 ++++++++++++++++++ product/ERP5SyncML/tests/testERP5SyncML.py | 4 ++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/product/ERP5SyncML/Conduit/ERP5Conduit.py b/product/ERP5SyncML/Conduit/ERP5Conduit.py index d261b082b6..3d14ba7407 100755 --- a/product/ERP5SyncML/Conduit/ERP5Conduit.py +++ b/product/ERP5SyncML/Conduit/ERP5Conduit.py @@ -390,7 +390,8 @@ class ERP5Conduit(XMLSyncUtilsMixin): # We will now apply the argument with the method edit if args != {} and (isConflict==0 or force) and (not simulate): LOG('updateNode',0,'object._edit, args: %s' % str(args)) - object._edit(**args) + #object._edit(**args) + self.editDocument(object=object,**args) # It is sometimes required to do something after an edit if hasattr(object,'manage_afterEdit'): object.manage_afterEdit() @@ -759,7 +760,8 @@ class ERP5Conduit(XMLSyncUtilsMixin): LOG('newObject',0,"args: %s" % str(args)) # edit the object with a dictionnary of arguments, # like {"telephone_number":"02-5648"} - object._edit(**args) + #object._edit(**args) + self.editDocument(object=object,**args) if hasattr(object,'manage_afterEdit'): object.manage_afterEdit() @@ -967,6 +969,14 @@ class ERP5Conduit(XMLSyncUtilsMixin): break return addable + def editDocument(self, object=None, **kw): + """ + This is the default editDocument method. This method + can easily be overwritten. + """ + object._edit(**kw) + + # This doesn't works fine because all workflows variables # are not set the same way # if status.has_key('action'): diff --git a/product/ERP5SyncML/SynchronizationTool.py b/product/ERP5SyncML/SynchronizationTool.py index 4ecf75e199..2826b1c88f 100755 --- a/product/ERP5SyncML/SynchronizationTool.py +++ b/product/ERP5SyncML/SynchronizationTool.py @@ -44,6 +44,7 @@ from PublicationSynchronization import PublicationSynchronization from SubscriptionSynchronization import SubscriptionSynchronization #import sys #import StringIO +import urllib import string from zLOG import * @@ -517,5 +518,22 @@ class SynchronizationTool( UniqueObject, SimpleItem, else: return context.getPhysicalPath() + def sendResponse(self,url=None, xml=None): + """ + We will look at the url and we will see if we need to send mail, http + response, or just copy to a file. + """ + if type(url) is type('a'): + if url.find('http://')==0: + # we will send an http response + to_encode = (('file',xml)) + encoded = urrlib.urlencode(to_encode) + urrlib.open(url, encoded).read() + elif url.find('file://')==0: + # we have to use local files (unit testing for example + pass + elif url.find('mailto:')==0: + # we will send an email + pass InitializeClass( SynchronizationTool ) diff --git a/product/ERP5SyncML/tests/testERP5SyncML.py b/product/ERP5SyncML/tests/testERP5SyncML.py index 893ab86e1d..5194abd868 100755 --- a/product/ERP5SyncML/tests/testERP5SyncML.py +++ b/product/ERP5SyncML/tests/testERP5SyncML.py @@ -933,6 +933,10 @@ class TestERP5SyncML(ERP5TypeTestCase): self.assertEqual(role_1_s,role_1_c) self.assertEqual(role_2_s,role_2_c) + # We may add a test in order to check if the slow_sync mode works fine, ie + # if we do have both object on the client and server side, we must make sure + # that the server first sends is own data + if __name__ == '__main__': framework() else: -- 2.30.9