From dad690455b3043e4f3fbd6e0f8baa26a6d684908 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Thu, 6 May 2004 12:04:09 +0000
Subject: [PATCH] make sure copies are deleted

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@848 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5SyncML/Subscription.py        |  3 ++-
 product/ERP5SyncML/SynchronizationTool.py | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/product/ERP5SyncML/Subscription.py b/product/ERP5SyncML/Subscription.py
index 853816ca11..a69be5a61c 100755
--- a/product/ERP5SyncML/Subscription.py
+++ b/product/ERP5SyncML/Subscription.py
@@ -615,7 +615,8 @@ class Subscription(SyncCode, Implicit):
     """
       return the xml mapping
     """
-    return self.xml_mapping
+    xml_mapping = getattr(self,'xml_mapping','asXML')
+    return xml_mapping
 
   def setXMLMapping(self, xml_mapping):
     """
diff --git a/product/ERP5SyncML/SynchronizationTool.py b/product/ERP5SyncML/SynchronizationTool.py
index 30b47daa03..a7920916ae 100755
--- a/product/ERP5SyncML/SynchronizationTool.py
+++ b/product/ERP5SyncML/SynchronizationTool.py
@@ -414,6 +414,11 @@ class SynchronizationTool( UniqueObject, SimpleItem,
     signature.delConflict(conflict)
     if signature.getConflictList() == []:
       LOG('p_sync.applyPublisherValue, conflict_list empty on : ',0,signature)
+      # Delete the copy of the object if the there is one
+      directory = object.aq_parent
+      copy_id = object.id + '_conflict_copy'
+      if copy_id in directory.objectIds():
+        directory._delObject(copy_id)
       signature.setStatus(self.PUB_CONFLICT_MERGE)
 
   security.declareProtected(Permissions.ModifyPortalContent, 'applyPublisherDocument')
@@ -428,7 +433,7 @@ class SynchronizationTool( UniqueObject, SimpleItem,
         LOG('applyPublisherDocument, applying on conflict: ',0,conflict)
         c.applyPublisherValue()
 
-  security.declareProtected(Permissions.ModifyPortalContent, 'getPublisherDocumentPath')
+  security.declareProtected(Permissions.AccessContentsInformation, 'getPublisherDocumentPath')
   def getPublisherDocumentPath(self, conflict):
     """
     apply the publisher value for all conflict of the given document
@@ -436,7 +441,7 @@ class SynchronizationTool( UniqueObject, SimpleItem,
     subscriber = conflict.getSubscriber()
     return conflict.getObjectPath()
 
-  security.declareProtected(Permissions.ModifyPortalContent, 'getPublisherDocument')
+  security.declareProtected(Permissions.AccessContentsInformation, 'getPublisherDocument')
   def getPublisherDocument(self, conflict):
     """
     apply the publisher value for all conflict of the given document
@@ -447,7 +452,7 @@ class SynchronizationTool( UniqueObject, SimpleItem,
     LOG('getPublisherDocument publisher_object',0,publisher_object)
     return publisher_object
 
-  security.declareProtected(Permissions.ModifyPortalContent, 'getSubscriberDocumentPath')
+  security.declareProtected(Permissions.AccessContentsInformation, 'getSubscriberDocumentPath')
   def getSubscriberDocumentPath(self, conflict):
     """
     apply the publisher value for all conflict of the given document
@@ -468,7 +473,7 @@ class SynchronizationTool( UniqueObject, SimpleItem,
         c.applySubscriberValue(object=subscriber_document)
     return subscriber_document.getPhysicalPath()
 
-  security.declareProtected(Permissions.ModifyPortalContent, 'getSubscriberDocument')
+  security.declareProtected(Permissions.AccessContentsInformation, 'getSubscriberDocument')
   def getSubscriberDocument(self, conflict):
     """
     apply the publisher value for all conflict of the given document
@@ -510,6 +515,11 @@ class SynchronizationTool( UniqueObject, SimpleItem,
     if solve_conflict:
       signature.delConflict(conflict)
       if signature.getConflictList() == []:
+        # Delete the copy of the object if the there is one
+        directory = object.aq_parent
+        copy_id = object.id + '_conflict_copy'
+        if copy_id in directory.objectIds():
+          directory._delObject(copy_id)
         signature.setStatus(self.PUB_CONFLICT_MERGE)
 
 
-- 
2.30.9