From e81320781749693c4c72bf1913d85408878153e4 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Fri, 23 Jul 2004 05:05:15 +0000 Subject: [PATCH] corrected bug recently introduced for the synchronization with cps git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1288 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5SyncML/Subscription.py | 23 ++++++++++++++++++-- product/ERP5SyncML/XMLSyncUtils.py | 25 ++++++++++++---------- product/ERP5SyncML/tests/testERP5SyncML.py | 7 ++++-- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/product/ERP5SyncML/Subscription.py b/product/ERP5SyncML/Subscription.py index 4b4212f2ea..664128038f 100755 --- a/product/ERP5SyncML/Subscription.py +++ b/product/ERP5SyncML/Subscription.py @@ -504,6 +504,26 @@ class Signature(Folder,SyncCode): """ return self.getParent().getObjectFromGid(self.getGid()) + def checkSynchronizationNeeded(self, object): + """ + We will look at date, if there is no changes, no need to syncrhonize + """ + last_modification = DateTime(object.ModificationDate()) + LOG('checkSynchronizationNeeded object.ModificationDate()',0,object.ModificationDate()) + last_synchronization = self.getLastSynchronizationDate() + parent = object.aq_parent + # XXX CPS Specific + if parent.id == 'portal_repository': # Make sure there is no sub objects + #if 1: + if last_synchronization is not None and last_modification is not None \ + and self.getSubscriberXupdate() is None and self.getPublisherXupdate() is None and \ + self.getStatus()==self.NOT_SYNCHRONIZED: + if last_synchronization > last_modification: + #if 1: + LOG('checkSynchronizationNeeded, no modification on: ',0,object.id) + self.setStatus(self.SYNCHRONIZED) + + def addSubscription( self, id, title='', REQUEST=None ): """ Add a new Subscribption @@ -985,12 +1005,10 @@ class Subscription(Folder, SyncCode): """ Reset all signatures """ - #self.signatures = PersistentMapping() while len(self.objectIds())>0: for id in self.objectIds(): self._delObject(id) - def getGidList(self): """ Returns the list of ids from signature @@ -1059,3 +1077,4 @@ class Subscription(Folder, SyncCode): o.setPartialXML(None) o.setTempXML(None) self.setRemainingObjectIdList(None) + diff --git a/product/ERP5SyncML/XMLSyncUtils.py b/product/ERP5SyncML/XMLSyncUtils.py index 0194ad683a..ead5ec4072 100755 --- a/product/ERP5SyncML/XMLSyncUtils.py +++ b/product/ERP5SyncML/XMLSyncUtils.py @@ -600,17 +600,20 @@ class XMLSyncUtilsMixin(SyncCode): LOG('getSyncMLData',0,'current object: %s' % str(object.getId())) # Here we first check if the object was modified or not by looking at dates if signature is not None: - LOG('getSyncMLData',0,'signature.status: %s' % str(signature.getStatus())) - LOG('getSyncMLData',0,'signature.action: %s' % str(signature.getAction())) - last_modification = DateTime(object.ModificationDate()) - last_synchronization = signature.getLastSynchronizationDate() - parent = object.aq_parent - # XXX CPS Specific - if parent.id == 'portal_repository': - if last_synchronization is not None and last_modification is not None: - if last_synchronization > last_modification: - LOG('getSyncMLData, no modification on: ',0,object.id) - signature.setStatus(self.SYNCHRONIZED) + signature.checkSynchronizationNeeded(object) +# LOG('getSyncMLData',0,'signature.status: %s' % str(signature.getStatus())) +# LOG('getSyncMLData',0,'signature.action: %s' % str(signature.getAction())) +# last_modification = DateTime(object.ModificationDate()) +# LOG('getSyncMLData object.ModificationDate()',0,object.ModificationDate()) +# last_synchronization = signature.getLastSynchronizationDate() +# parent = object.aq_parent +# # XXX CPS Specific +# #if parent.id == 'portal_repository': +# if 1: +# if last_synchronization is not None and last_modification is not None: +# if last_synchronization > last_modification: +# LOG('getSyncMLData, no modification on: ',0,object.id) +# signature.setStatus(self.SYNCHRONIZED) status = self.SENT more_data=0 # For the case it was never synchronized, we have to send everything diff --git a/product/ERP5SyncML/tests/testERP5SyncML.py b/product/ERP5SyncML/tests/testERP5SyncML.py index fafe1936c0..ddecab35e2 100755 --- a/product/ERP5SyncML/tests/testERP5SyncML.py +++ b/product/ERP5SyncML/tests/testERP5SyncML.py @@ -44,6 +44,8 @@ os.environ['EVENT_LOG_SEVERITY'] = '-300' from Testing import ZopeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase +from DateTime import DateTime +from Products.ERP5.Document.Person import Person from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from Products.ERP5SyncML.SyncCode import SyncCode @@ -532,8 +534,6 @@ class TestERP5SyncML(ERP5TypeTestCase): self.failUnless(state[1]==state[0].CONFLICT) def testUpdateSimpleData(self, quiet=0, run=run_all_test): - # We will try to update some simple data, first - # we change on the server side, the on the client side if not run: return if not quiet: ZopeTestCase._print('\nTest Update Simple Data ') @@ -556,6 +556,7 @@ class TestERP5SyncML(ERP5TypeTestCase): # Then we do only modification on a client kw = {'first_name':self.first_name1,'last_name':self.last_name1} person1_c.edit(**kw) + #person1_c.setModificationDate(DateTime()+1) self.synchronize(self.sub_id1) self.checkSynchronizationStateIsSynchronized() self.failUnless(person1_s.getFirstName()==self.first_name1) @@ -566,8 +567,10 @@ class TestERP5SyncML(ERP5TypeTestCase): # and of course, on the same object kw = {'first_name':self.first_name3} person1_s.edit(**kw) + #person1_s.setModificationDate(DateTime()+2) kw = {'description':self.description3} person1_c.edit(**kw) + #person1_c.setModificationDate(DateTime()+2) self.synchronize(self.sub_id1) self.checkSynchronizationStateIsSynchronized() self.failUnless(person1_s.getFirstName()==self.first_name3) -- 2.30.9