Commit e8132078 authored by Sebastien Robin's avatar Sebastien Robin

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
parent 01f6927b
...@@ -504,6 +504,26 @@ class Signature(Folder,SyncCode): ...@@ -504,6 +504,26 @@ class Signature(Folder,SyncCode):
""" """
return self.getParent().getObjectFromGid(self.getGid()) 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 ): def addSubscription( self, id, title='', REQUEST=None ):
""" """
Add a new Subscribption Add a new Subscribption
...@@ -985,12 +1005,10 @@ class Subscription(Folder, SyncCode): ...@@ -985,12 +1005,10 @@ class Subscription(Folder, SyncCode):
""" """
Reset all signatures Reset all signatures
""" """
#self.signatures = PersistentMapping()
while len(self.objectIds())>0: while len(self.objectIds())>0:
for id in self.objectIds(): for id in self.objectIds():
self._delObject(id) self._delObject(id)
def getGidList(self): def getGidList(self):
""" """
Returns the list of ids from signature Returns the list of ids from signature
...@@ -1059,3 +1077,4 @@ class Subscription(Folder, SyncCode): ...@@ -1059,3 +1077,4 @@ class Subscription(Folder, SyncCode):
o.setPartialXML(None) o.setPartialXML(None)
o.setTempXML(None) o.setTempXML(None)
self.setRemainingObjectIdList(None) self.setRemainingObjectIdList(None)
...@@ -600,17 +600,20 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -600,17 +600,20 @@ class XMLSyncUtilsMixin(SyncCode):
LOG('getSyncMLData',0,'current object: %s' % str(object.getId())) LOG('getSyncMLData',0,'current object: %s' % str(object.getId()))
# Here we first check if the object was modified or not by looking at dates # Here we first check if the object was modified or not by looking at dates
if signature is not None: if signature is not None:
LOG('getSyncMLData',0,'signature.status: %s' % str(signature.getStatus())) signature.checkSynchronizationNeeded(object)
LOG('getSyncMLData',0,'signature.action: %s' % str(signature.getAction())) # LOG('getSyncMLData',0,'signature.status: %s' % str(signature.getStatus()))
last_modification = DateTime(object.ModificationDate()) # LOG('getSyncMLData',0,'signature.action: %s' % str(signature.getAction()))
last_synchronization = signature.getLastSynchronizationDate() # last_modification = DateTime(object.ModificationDate())
parent = object.aq_parent # LOG('getSyncMLData object.ModificationDate()',0,object.ModificationDate())
# XXX CPS Specific # last_synchronization = signature.getLastSynchronizationDate()
if parent.id == 'portal_repository': # parent = object.aq_parent
if last_synchronization is not None and last_modification is not None: # # XXX CPS Specific
if last_synchronization > last_modification: # #if parent.id == 'portal_repository':
LOG('getSyncMLData, no modification on: ',0,object.id) # if 1:
signature.setStatus(self.SYNCHRONIZED) # 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 status = self.SENT
more_data=0 more_data=0
# For the case it was never synchronized, we have to send everything # For the case it was never synchronized, we have to send everything
......
...@@ -44,6 +44,8 @@ os.environ['EVENT_LOG_SEVERITY'] = '-300' ...@@ -44,6 +44,8 @@ os.environ['EVENT_LOG_SEVERITY'] = '-300'
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase 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 AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit
from Products.ERP5SyncML.SyncCode import SyncCode from Products.ERP5SyncML.SyncCode import SyncCode
...@@ -532,8 +534,6 @@ class TestERP5SyncML(ERP5TypeTestCase): ...@@ -532,8 +534,6 @@ class TestERP5SyncML(ERP5TypeTestCase):
self.failUnless(state[1]==state[0].CONFLICT) self.failUnless(state[1]==state[0].CONFLICT)
def testUpdateSimpleData(self, quiet=0, run=run_all_test): 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 run: return
if not quiet: if not quiet:
ZopeTestCase._print('\nTest Update Simple Data ') ZopeTestCase._print('\nTest Update Simple Data ')
...@@ -556,6 +556,7 @@ class TestERP5SyncML(ERP5TypeTestCase): ...@@ -556,6 +556,7 @@ class TestERP5SyncML(ERP5TypeTestCase):
# Then we do only modification on a client # Then we do only modification on a client
kw = {'first_name':self.first_name1,'last_name':self.last_name1} kw = {'first_name':self.first_name1,'last_name':self.last_name1}
person1_c.edit(**kw) person1_c.edit(**kw)
#person1_c.setModificationDate(DateTime()+1)
self.synchronize(self.sub_id1) self.synchronize(self.sub_id1)
self.checkSynchronizationStateIsSynchronized() self.checkSynchronizationStateIsSynchronized()
self.failUnless(person1_s.getFirstName()==self.first_name1) self.failUnless(person1_s.getFirstName()==self.first_name1)
...@@ -566,8 +567,10 @@ class TestERP5SyncML(ERP5TypeTestCase): ...@@ -566,8 +567,10 @@ class TestERP5SyncML(ERP5TypeTestCase):
# and of course, on the same object # and of course, on the same object
kw = {'first_name':self.first_name3} kw = {'first_name':self.first_name3}
person1_s.edit(**kw) person1_s.edit(**kw)
#person1_s.setModificationDate(DateTime()+2)
kw = {'description':self.description3} kw = {'description':self.description3}
person1_c.edit(**kw) person1_c.edit(**kw)
#person1_c.setModificationDate(DateTime()+2)
self.synchronize(self.sub_id1) self.synchronize(self.sub_id1)
self.checkSynchronizationStateIsSynchronized() self.checkSynchronizationStateIsSynchronized()
self.failUnless(person1_s.getFirstName()==self.first_name3) self.failUnless(person1_s.getFirstName()==self.first_name3)
......
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