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
No related merge requests found
......@@ -394,7 +394,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
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)
......@@ -852,19 +851,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
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 = ''
......@@ -881,19 +867,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
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):
"""
......
......@@ -330,7 +330,7 @@ class XMLSyncUtilsMixin(SyncCode):
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 @@ class XMLSyncUtilsMixin(SyncCode):
# 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,
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
for known_gid in subscriber.getGidList():
if known_gid not in local_gid_list:
subscriber.delSignature(known_gid)
subscriber.delSignature(object_gid)
local_gid_list = []
loop = 0
for object_path in subscriber.getRemainingObjectPathList():
......@@ -746,8 +738,8 @@ class XMLSyncUtilsMixin(SyncCode):
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 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
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 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
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)
......
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