Commit feb9aeda authored by Nicolas Delaby's avatar Nicolas Delaby

- Etree Object are not Pickable (convert to string for CMFActivity)

- remove unused arguments and obselete code


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25371 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b09efaef
...@@ -394,23 +394,22 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -394,23 +394,22 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if previous_xml is not None and sub_object_id is not None: if previous_xml is not None and sub_object_id is not None:
sub_previous_xml = self.getSubObjectXml(sub_object_id, previous_xml) sub_previous_xml = self.getSubObjectXml(sub_object_id, previous_xml)
#LOG('ERP5Conduit.updateNode', DEBUG, 'isSubObjectModification sub_previous_xml: %s' % str(sub_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
sub_object = None try:
try: sub_object = object._getOb(sub_object_id)
sub_object = object._getOb(sub_object_id) except KeyError:
except KeyError: pass
pass if sub_object is not None:
if sub_object is not None: #LOG('ERP5Conduit.updateNode', DEBUG, 'subobject.id: %s' % sub_object.id)
#LOG('ERP5Conduit.updateNode', DEBUG, 'subobject.id: %s' % sub_object.id) # Change the xml in order to directly apply
# Change the xml in order to directly apply # modifications to the subobject
# modifications to the subobject sub_xml = self.getSubObjectXupdate(xml)
sub_xml = self.getSubObjectXupdate(xml) #LOG('ERP5Conduit.updateNode', DEBUG, 'sub_xml: %s' % str(sub_xml))
#LOG('ERP5Conduit.updateNode', DEBUG, 'sub_xml: %s' % str(sub_xml)) # Then do the udpate
# Then do the udpate conflict_list += self.updateNode(xml=sub_xml, object=sub_object,
conflict_list += self.updateNode(xml=sub_xml, object=sub_object, force=force,
force=force, previous_xml=sub_previous_xml,
previous_xml=sub_previous_xml, simulate=simulate, **kw)
simulate=simulate, **kw)
elif previous_xml is None and xml is not None and sub_object_id is not None: elif previous_xml is None and xml is not None and sub_object_id is not None:
sub_object = None sub_object = None
try: try:
...@@ -852,19 +851,6 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -852,19 +851,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
conflict_list = [] conflict_list = []
if isinstance(xupdate, (str, unicode)): if isinstance(xupdate, (str, unicode)):
xupdate = etree.XML(xupdate, parser=parser) 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: for subnode in xupdate:
sub_xupdate = self.getSubObjectXupdate(subnode) sub_xupdate = self.getSubObjectXupdate(subnode)
selection_name = '' selection_name = ''
...@@ -881,19 +867,6 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -881,19 +867,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
return conflict_list 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, def isWorkflowActionAddable(self, object=None, status=None, wf_tool=None,
wf_id=None, xml=None): wf_id=None, xml=None):
""" """
......
...@@ -330,7 +330,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -330,7 +330,7 @@ class XMLSyncUtilsMixin(SyncCode):
item_node.append(Element('MoreData')) item_node.append(Element('MoreData'))
return etree.tostring(xml, encoding='utf-8', pretty_print=True) 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 Delete an object with the SyncML protocol
""" """
...@@ -664,28 +664,20 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -664,28 +664,20 @@ class XMLSyncUtilsMixin(SyncCode):
# Objects to remove # Objects to remove
#LOG('getSyncMLData remove object to remove ...', DEBUG, '') #LOG('getSyncMLData remove object to remove ...', DEBUG, '')
object_gid_deleted = []
for object_gid in subscriber.getGidList(): for object_gid in subscriber.getGidList():
if object_gid not in local_gid_list: if object_gid not in local_gid_list:
# This is an object to remove # This is an object to remove
signature = subscriber.getSignatureFromGid(object_gid) signature = subscriber.getSignatureFromGid(object_gid)
if signature.getStatus() != self.PARTIAL: if signature.getStatus() != self.PARTIAL:
# If partial, then we have a signature but no local object # If partial, then we have a signature but no local object
xml_object = signature.getXML() rid = signature.getRid()
if xml_object is not None: # This prevent to delete an object that syncml_data_list.append(self.deleteXMLObject(object_gid=object_gid,
# we were not able to create rid=rid,
rid = signature.getRid() cmd_id=cmd_id))
object_gid_deleted.append(object_gid) cmd_id += 1
syncml_data_list.append(self.deleteXMLObject( #delete Signature if object does not exist anymore
xml_object=signature.getXML() or '', subscriber.delSignature(object_gid)
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)
local_gid_list = [] local_gid_list = []
loop = 0 loop = 0
for object_path in subscriber.getRemainingObjectPathList(): for object_path in subscriber.getRemainingObjectPathList():
...@@ -746,8 +738,8 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -746,8 +738,8 @@ class XMLSyncUtilsMixin(SyncCode):
cmd_id += 1 cmd_id += 1
signature.setStatus(status) signature.setStatus(status)
subscriber.addSignature(signature) subscriber.addSignature(signature)
elif signature.getStatus() == self.NOT_SYNCHRONIZED \ elif signature.getStatus() in (self.NOT_SYNCHRONIZED,
or signature.getStatus() == self.PUB_CONFLICT_MERGE: self.PUB_CONFLICT_MERGE,):
# We don't have synchronized this object yet # We don't have synchronized this object yet
xml_object = domain.getXMLFromObject(object) xml_object = domain.getXMLFromObject(object)
#LOG('getSyncMLData', DEBUG, 'checkMD5: %s' % str(signature.checkMD5(xml_object))) #LOG('getSyncMLData', DEBUG, 'checkMD5: %s' % str(signature.checkMD5(xml_object)))
...@@ -1265,6 +1257,10 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1265,6 +1257,10 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
xml_declaration=True, pretty_print=False) xml_declaration=True, pretty_print=False)
xml_tree = etree.tostring(xml, encoding='utf-8', xml_declaration=True, xml_tree = etree.tostring(xml, encoding='utf-8', xml_declaration=True,
pretty_print=False) 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', domain.activate(activity='SQLQueue',
tag=domain.getId(), tag=domain.getId(),
priority=self.PRIORITY).activateSyncModif( priority=self.PRIORITY).activateSyncModif(
...@@ -1377,7 +1373,11 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1377,7 +1373,11 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
sync_node.append(E.Source(E.LocURI(source_uri))) sync_node.append(E.Source(E.LocURI(source_uri)))
for syncml_data in syncml_data_list: for syncml_data in syncml_data_list:
sync_node.append(etree.XML(syncml_data, parser=parser)) 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')) sync_body.append(Element('Final'))
xml_string = etree.tostring(xml_tree, encoding='utf-8', pretty_print=True) xml_string = etree.tostring(xml_tree, encoding='utf-8', pretty_print=True)
......
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