[Erp5-report] r25371 - in /erp5/trunk/products/ERP5SyncML: ./ Conduit/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jan 30 00:13:04 CET 2009


Author: nicolas
Date: Fri Jan 30 00:13:03 2009
New Revision: 25371

URL: http://svn.erp5.org?rev=25371&view=rev
Log:
- Etree Object are not Pickable (convert to string for CMFActivity)
- remove unused arguments and obselete code

Modified:
    erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
    erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py

Modified: erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py?rev=25371&r1=25370&r2=25371&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py [utf8] Fri Jan 30 00:13:03 2009
@@ -394,23 +394,22 @@
         if previous_xml is not None and sub_object_id is not None:
           sub_previous_xml = self.getSubObjectXml(sub_object_id, previous_xml)
           #LOG('ERP5Conduit.updateNode', DEBUG, 'isSubObjectModification sub_previous_xml: %s' % str(sub_previous_xml))
-          if sub_previous_xml is not None:
-            sub_object = None
-            try:
-              sub_object = object._getOb(sub_object_id)
-            except KeyError:
-              pass
-            if sub_object is not None:
-              #LOG('ERP5Conduit.updateNode', DEBUG, 'subobject.id: %s' % sub_object.id)
-              # Change the xml in order to directly apply
-              # modifications to the subobject
-              sub_xml = self.getSubObjectXupdate(xml)
-              #LOG('ERP5Conduit.updateNode', DEBUG, 'sub_xml: %s' % str(sub_xml))
-              # Then do the udpate
-              conflict_list += self.updateNode(xml=sub_xml, object=sub_object,
-                                               force=force,
-                                               previous_xml=sub_previous_xml,
-                                               simulate=simulate, **kw)
+          sub_object = None
+          try:
+            sub_object = object._getOb(sub_object_id)
+          except KeyError:
+            pass
+          if sub_object is not None:
+            #LOG('ERP5Conduit.updateNode', DEBUG, 'subobject.id: %s' % sub_object.id)
+            # Change the xml in order to directly apply
+            # modifications to the subobject
+            sub_xml = self.getSubObjectXupdate(xml)
+            #LOG('ERP5Conduit.updateNode', DEBUG, 'sub_xml: %s' % str(sub_xml))
+            # Then do the udpate
+            conflict_list += self.updateNode(xml=sub_xml, object=sub_object,
+                                              force=force,
+                                              previous_xml=sub_previous_xml,
+                                              simulate=simulate, **kw)
         elif previous_xml is None and xml is not None and sub_object_id is not None:
           sub_object = None
           try:
@@ -852,19 +851,6 @@
     conflict_list = []
     if isinstance(xupdate, (str, unicode)):
       xupdate = etree.XML(xupdate, parser=parser)
-    #When xupdate mix different object, (like object and his subobject) we need to treat them separatly
-    if self.isMixedXupdate(xupdate):
-      #return to updateNode with only one line
-      #del all sub_element
-      #clean the node
-      for subnode in xupdate:
-        #Create one xupdate:modification per update node
-        conflict_list += self.updateNode(xml=subnode,
-                                         object=object,
-                                         force=force,
-                                         simulate=simulate,
-                                         **kw)
-      return conflict_list
     for subnode in xupdate:
       sub_xupdate = self.getSubObjectXupdate(subnode)
       selection_name = ''
@@ -880,19 +866,6 @@
                                             force=force, simulate=simulate, **kw)
 
     return conflict_list
-
-  def isMixedXupdate(self, xml):
-    #If an xupdate:modifications contains modification which concerns different objects
-    subnode_list = xml
-    nb_sub = len(subnode_list)
-    comp = 0
-    for subnode in subnode_list:
-      value = self.getAttribute(subnode, 'select')
-      if self.object_exp.search(value) is not None:
-        comp += 1
-    if nb_sub == comp:
-      return 0
-    return 1
 
   def isWorkflowActionAddable(self, object=None, status=None, wf_tool=None,
                               wf_id=None, xml=None):

Modified: erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py?rev=25371&r1=25370&r2=25371&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py [utf8] Fri Jan 30 00:13:03 2009
@@ -330,7 +330,7 @@
       item_node.append(Element('MoreData'))
     return etree.tostring(xml, encoding='utf-8', pretty_print=True)
 
-  def deleteXMLObject(self, cmd_id=0, object_gid=None, rid=None, xml_object=''):
+  def deleteXMLObject(self, cmd_id=0, object_gid=None, rid=None):
     """
       Delete an object with the SyncML protocol
     """
@@ -664,28 +664,20 @@
 
       # Objects to remove
       #LOG('getSyncMLData remove object to remove ...', DEBUG, '')
-      object_gid_deleted = []
       for object_gid in subscriber.getGidList():
         if object_gid not in local_gid_list:
           # This is an object to remove
           signature = subscriber.getSignatureFromGid(object_gid)
           if signature.getStatus() != self.PARTIAL:
             # If partial, then we have a signature but no local object
-            xml_object = signature.getXML()
-            if xml_object is not None: # This prevent to delete an object that
-                                       # we were not able to create
-              rid = signature.getRid()
-              object_gid_deleted.append(object_gid)
-              syncml_data_list.append(self.deleteXMLObject(
-                                      xml_object=signature.getXML() or '',
-                                      object_gid=object_gid,
-                                      rid=rid,
-                                      cmd_id=cmd_id))
-              cmd_id += 1
-      #delete Signature if object does not exist anymore
-      for known_gid in subscriber.getGidList():
-        if known_gid not in local_gid_list:
-          subscriber.delSignature(known_gid)
+            rid = signature.getRid()
+            syncml_data_list.append(self.deleteXMLObject(object_gid=object_gid,
+                                                         rid=rid,
+                                                         cmd_id=cmd_id))
+            cmd_id += 1
+          #delete Signature if object does not exist anymore
+          subscriber.delSignature(object_gid)
+
     local_gid_list = []
     loop = 0
     for object_path in subscriber.getRemainingObjectPathList():
@@ -746,8 +738,8 @@
           cmd_id += 1
           signature.setStatus(status)
           subscriber.addSignature(signature)
-        elif signature.getStatus() == self.NOT_SYNCHRONIZED \
-            or signature.getStatus() == self.PUB_CONFLICT_MERGE:
+        elif signature.getStatus() in (self.NOT_SYNCHRONIZED,
+                                       self.PUB_CONFLICT_MERGE,):
           # We don't have synchronized this object yet
           xml_object = domain.getXMLFromObject(object)
           #LOG('getSyncMLData', DEBUG, 'checkMD5: %s' % str(signature.checkMD5(xml_object)))
@@ -1265,6 +1257,10 @@
                                     xml_declaration=True, pretty_print=False)
       xml_tree = etree.tostring(xml, encoding='utf-8', xml_declaration=True,
                                 pretty_print=False)
+      xml_confirmation_list = [etree.tostring(xml, encoding='utf-8',\
+                                              xml_declaration=True,\
+                                              pretty_print=False) for xml in \
+                                              xml_confirmation_list]
       domain.activate(activity='SQLQueue',
                       tag=domain.getId(),
                       priority=self.PRIORITY).activateSyncModif(
@@ -1377,7 +1373,11 @@
         sync_node.append(E.Source(E.LocURI(source_uri)))
       for syncml_data in syncml_data_list:
         sync_node.append(etree.XML(syncml_data, parser=parser))
-    sync_body.extend(xml_confirmation_list)
+    for xml_confirmation in xml_confirmation_list:
+      if not isinstance(xml_confirmation, str):
+        sync_body.append(xml_confirmation)
+      else:
+        sync_body.append(etree.XML(xml_confirmation, parser=parser))
     sync_body.append(Element('Final'))
     xml_string = etree.tostring(xml_tree, encoding='utf-8', pretty_print=True)
 




More information about the Erp5-report mailing list