Commit 5cb78a69 authored by Sebastien Robin's avatar Sebastien Robin

quick hack in order to get directly the object from addNode, this save a lot...

quick hack in order to get directly the object from addNode, this save a lot of time because we do not need to parse all object any more, but the patch is dirty and must be reviewed

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14257 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29d03875
...@@ -125,6 +125,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -125,6 +125,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
[object.getPath(),keyword,local_and_actual_value,subscriber_value] [object.getPath(),keyword,local_and_actual_value,subscriber_value]
""" """
conflict_list = [] conflict_list = []
sub_object = None
xml = self.convertToXml(xml) xml = self.convertToXml(xml)
LOG('addNode',0,'xml_reconstitued: %s' % str(xml)) LOG('addNode',0,'xml_reconstitued: %s' % str(xml))
# In the case where this new node is a object to add # In the case where this new node is a object to add
...@@ -139,7 +140,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -139,7 +140,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
xml = self.getElementFromXupdate(element) xml = self.getElementFromXupdate(element)
conflict_list += self.addNode(xml=xml,object=object, conflict_list += self.addNode(xml=xml,object=object,
previous_xml=previous_xml, force=force, previous_xml=previous_xml, force=force,
simulate=simulate, **kw) simulate=simulate, **kw)['conflict_list']
elif xml.nodeName == 'object': elif xml.nodeName == 'object':
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml,'id') object_id = self.getAttribute(xml,'id')
...@@ -147,17 +148,17 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -147,17 +148,17 @@ class ERP5Conduit(XMLSyncUtilsMixin):
LOG('addNode',0,'object_id: %s' % object_id) LOG('addNode',0,'object_id: %s' % object_id)
if object_id is not None: if object_id is not None:
try: try:
subobject = object._getOb(object_id) sub_object = object._getOb(object_id)
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
subobject = None sub_object = None
if subobject is None: # If so, it doesn't exist if sub_object is None: # If so, it doesn't exist
portal_type = '' portal_type = ''
if xml.nodeName == 'object': if xml.nodeName == 'object':
portal_type = self.getObjectType(xml) portal_type = self.getObjectType(xml)
elif xml.nodeName in self.XUPDATE_INSERT_OR_ADD: # Deprecated ??? elif xml.nodeName in self.XUPDATE_INSERT_OR_ADD: # Deprecated ???
portal_type = self.getXupdateObjectType(xml) # Deprecated ??? portal_type = self.getXupdateObjectType(xml) # Deprecated ???
subobject = self.constructContent(object, object_id, docid, portal_type) sub_object = self.constructContent(object, object_id, docid, portal_type)
self.newObject(object=subobject,xml=xml,simulate=simulate) self.newObject(object=sub_object,xml=xml,simulate=simulate)
elif xml.nodeName in self.XUPDATE_INSERT_OR_ADD \ elif xml.nodeName in self.XUPDATE_INSERT_OR_ADD \
and self.getSubObjectDepth(xml)>=1: and self.getSubObjectDepth(xml)>=1:
sub_object_id = self.getSubObjectId(xml) sub_object_id = self.getSubObjectId(xml)
...@@ -182,7 +183,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -182,7 +183,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
# Then do the udpate # Then do the udpate
conflict_list += self.addNode(xml=sub_xml,object=sub_object, conflict_list += self.addNode(xml=sub_xml,object=sub_object,
previous_xml=sub_previous_xml, force=force, previous_xml=sub_previous_xml, force=force,
simulate=simulate, **kw) simulate=simulate, **kw)['conflict_list']
elif xml.nodeName == self.history_tag or self.isHistoryAdd(xml)>0: elif xml.nodeName == self.history_tag or self.isHistoryAdd(xml)>0:
conflict_list += self.addWorkflowNode(object, xml, simulate) conflict_list += self.addWorkflowNode(object, xml, simulate)
#elif xml.nodeName in self.local_role_list or self.isLocalRole(xml)>0 and not simulate: #elif xml.nodeName in self.local_role_list or self.isLocalRole(xml)>0 and not simulate:
...@@ -193,7 +194,8 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -193,7 +194,8 @@ class ERP5Conduit(XMLSyncUtilsMixin):
else: else:
conflict_list += self.updateNode(xml=xml,object=object, force=force, conflict_list += self.updateNode(xml=xml,object=object, force=force,
simulate=simulate, **kw) simulate=simulate, **kw)
return conflict_list # We must returns the object created
return {'conflict_list':conflict_list, 'object': sub_object}
security.declareProtected(Permissions.ModifyPortalContent, 'deleteNode') security.declareProtected(Permissions.ModifyPortalContent, 'deleteNode')
def deleteNode(self, xml=None, object=None, object_id=None, force=None, def deleteNode(self, xml=None, object=None, object_id=None, force=None,
...@@ -359,12 +361,12 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -359,12 +361,12 @@ class ERP5Conduit(XMLSyncUtilsMixin):
# This is the case where we have to call addNode # This is the case where we have to call addNode
LOG('updateNode',0,'we will add sub-object') LOG('updateNode',0,'we will add sub-object')
conflict_list += self.addNode(xml=subnode,object=object,force=force, conflict_list += self.addNode(xml=subnode,object=object,force=force,
simulate=simulate, **kw) simulate=simulate, **kw)['conflict_list']
elif keyword == self.history_tag and not simulate: elif keyword == self.history_tag and not simulate:
# This is the case where we have to call addNode # This is the case where we have to call addNode
LOG('updateNode',0,'we will add history') LOG('updateNode',0,'we will add history')
conflict_list += self.addNode(xml=subnode,object=object,force=force, conflict_list += self.addNode(xml=subnode,object=object,force=force,
simulate=simulate,**kw) simulate=simulate,**kw)['conflict_list']
elif keyword in (self.local_role_tag,self.local_permission_tag) and not simulate: elif keyword in (self.local_role_tag,self.local_permission_tag) and not simulate:
# This is the case where we have to update Roles or update permission # This is the case where we have to update Roles or update permission
LOG('updateNode',0,'we will add a local role') LOG('updateNode',0,'we will add a local role')
...@@ -373,7 +375,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -373,7 +375,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
#object.manage_setLocalRoles(user,roles) #object.manage_setLocalRoles(user,roles)
xml = self.getElementFromXupdate(xml) xml = self.getElementFromXupdate(xml)
conflict_list += self.addNode(xml=xml,object=object,force=force, conflict_list += self.addNode(xml=xml,object=object,force=force,
simulate=simulate,**kw) simulate=simulate,**kw)['conflict_list']
elif self.isSubObjectModification(xml): elif self.isSubObjectModification(xml):
# We should find the object corresponding to # We should find the object corresponding to
# this update, so we have to look in the previous_xml # this update, so we have to look in the previous_xml
...@@ -902,7 +904,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -902,7 +904,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
selection_name = '' selection_name = ''
if subnode.nodeName in self.XUPDATE_INSERT_OR_ADD: if subnode.nodeName in self.XUPDATE_INSERT_OR_ADD:
conflict_list += conduit.addNode(xml=sub_xupdate,object=object, \ conflict_list += conduit.addNode(xml=sub_xupdate,object=object, \
force=force, simulate=simulate, **kw) force=force, simulate=simulate, **kw)['conflict_list']
elif subnode.nodeName in self.XUPDATE_DEL: elif subnode.nodeName in self.XUPDATE_DEL:
conflict_list += conduit.deleteNode(xml=sub_xupdate, object=object, \ conflict_list += conduit.deleteNode(xml=sub_xupdate, object=object, \
force=force, simulate=simulate, **kw) force=force, simulate=simulate, **kw)
......
...@@ -512,6 +512,9 @@ class Signature(Folder,SyncCode): ...@@ -512,6 +512,9 @@ class Signature(Folder,SyncCode):
Return the actual action for a partial synchronization Return the actual action for a partial synchronization
""" """
LOG('setConflictList, list',0,conflict_list) LOG('setConflictList, list',0,conflict_list)
for conflict in conflict_list:
if isinstance(conflict,str):
import pdb; pdb.set_trace()
if conflict_list is None or conflict_list==[]: if conflict_list is None or conflict_list==[]:
self.resetConflictList() self.resetConflictList()
else: else:
......
...@@ -385,7 +385,10 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -385,7 +385,10 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
conflict_list += [conflict.__of__(subscriber)] conflict_list += [conflict.__of__(subscriber)]
for subscription in self.getSubscriptionList(): for subscription in self.getSubscriptionList():
sub_conflict_list = subscription.getConflictList() sub_conflict_list = subscription.getConflictList()
LOG('SynchronizationTool.getConflictList, sub_conflict_list',0,sub_conflict_list)
for conflict in sub_conflict_list: for conflict in sub_conflict_list:
if isinstance(conflict,str):
import pdb; pdb.set_trace()
#conflict.setDomain('Subscription') #conflict.setDomain('Subscription')
conflict.setSubscriber(subscription) conflict.setSubscriber(subscription)
#conflict.setDomainId(subscription.getId()) #conflict.setDomainId(subscription.getId())
......
...@@ -772,9 +772,12 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -772,9 +772,12 @@ class XMLSyncUtilsMixin(SyncCode):
if object is None: if object is None:
object_id = domain.generateNewIdWithGenerator(object=destination_path,gid=object_gid) object_id = domain.generateNewIdWithGenerator(object=destination_path,gid=object_gid)
#if object_id is not None: #if object_id is not None:
conflict_list += conduit.addNode(xml=data_subnode, object=destination_path, add_data = conduit.addNode(xml=data_subnode, object=destination_path,
object_id=object_id) object_id=object_id)
object = domain.getObjectFromGid(object_gid) conflict_list += add_data['conflict_list']
# Retrieve directly the object from addNode
object = add_data['object']
LOG('XMLSyncUtils, in ADD add_data',0,add_data)
signature.setPath(object.getPhysicalPath()) signature.setPath(object.getPhysicalPath())
LOG('applyActionList',0,'object after add: %s' % repr(object)) LOG('applyActionList',0,'object after add: %s' % repr(object))
if object is not None: if object is not None:
......
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