Commit 3e4039c5 authored by Aurel's avatar Aurel

object_id is no longer provided by synchronization tool

parent a3e3dacd
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
# #
############################################################################## ##############################################################################
from Products.ERP5SyncML.SyncMLConstant import XUPDATE_ELEMENT,\ from Products.ERP5SyncML.SyncMLConstant import XUPDATE_INSERT_OR_ADD_LIST, \
XUPDATE_INSERT_OR_ADD_LIST, XUPDATE_DEL, XUPDATE_UPDATE XUPDATE_DEL, XUPDATE_UPDATE
from Products.ERP5Type.XMLExportImport import MARSHALLER_NAMESPACE_URI from Products.ERP5Type.XMLExportImport import MARSHALLER_NAMESPACE_URI
from zLOG import LOG, INFO from zLOG import LOG, INFO
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit
......
633 634
\ No newline at end of file \ No newline at end of file
...@@ -114,7 +114,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit): ...@@ -114,7 +114,7 @@ class OscommerceERP5NodeConduit(TioSafeBaseConduit):
""" This is the method calling to create an object. """ """ This is the method calling to create an object. """
if DEBUG: if DEBUG:
LOG("ERP5NodeContuide._createContent", INFO, "xml = %s" %(etree.tostring(xml, pretty_print=True),)) LOG("ERP5NodeContuide._createContent", INFO, "xml = %s" %(etree.tostring(xml, pretty_print=True),))
if object_id is not None: if True: # object_id is not None:
sub_object = None sub_object = None
if sub_object is None: # If so, it doesn't exist if sub_object is None: # If so, it doesn't exist
sub_object, reset_local_roles, reset_workflow = self.constructContent( sub_object, reset_local_roles, reset_workflow = self.constructContent(
......
...@@ -59,8 +59,8 @@ class OscommerceERP5TransactionConduit(TioSafeBaseConduit): ...@@ -59,8 +59,8 @@ class OscommerceERP5TransactionConduit(TioSafeBaseConduit):
""" """
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml, 'id') object_id = self.getAttribute(xml, 'id')
if object_id is not None: if True: # object_id is not None:
if sub_object is None: if sub_object is None and object_id:
try: try:
sub_object = object._getOb(object_id) sub_object = object._getOb(object_id)
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
......
292 293
\ No newline at end of file \ No newline at end of file
...@@ -59,8 +59,8 @@ class ERP5TransactionConduit(TioSafeBaseConduit): ...@@ -59,8 +59,8 @@ class ERP5TransactionConduit(TioSafeBaseConduit):
""" """
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml, 'id') object_id = self.getAttribute(xml, 'id')
if object_id is not None: if True: # object_id is not None:
if sub_object is None: if sub_object is None and object_id:
try: try:
sub_object = object._getOb(object_id) sub_object = object._getOb(object_id)
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
......
33 34
\ No newline at end of file \ No newline at end of file
...@@ -931,7 +931,8 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -931,7 +931,8 @@ class ERP5Conduit(XMLSyncUtilsMixin):
This is really usefull if you want to write your This is really usefull if you want to write your
own Conduit. own Conduit.
""" """
#LOG('ERP5Conduit.addNode',0,'portal_type: |%s|' % str(portal_type)) from zLOG import LOG
LOG('ERP5Conduit.addNode',0,'portal_type: |%s|' % str(portal_type))
subobject = object.newContent(portal_type=portal_type, id=object_id) subobject = object.newContent(portal_type=portal_type, id=object_id)
return subobject, True, True return subobject, True, True
......
...@@ -129,13 +129,13 @@ class SyncMLSubscription(XMLObject): ...@@ -129,13 +129,13 @@ class SyncMLSubscription(XMLObject):
result_count = len(r) result_count = len(r)
generated_other_activity = False generated_other_activity = False
if result_count: if result_count:
syncml_logger.info("getAndActivate : got %d result, limit = %d, packet %d" % syncml_logger.debug("getAndActivate : got %d result, limit = %d, packet %d" %
(result_count, limit, packet_size)) (result_count, limit, packet_size))
if result_count == limit: if result_count == limit:
# Recursive call to prevent too many activity generation # Recursive call to prevent too many activity generation
next_kw = dict(activate_kw, priority=1+activate_kw.get('priority', 1)) next_kw = dict(activate_kw, priority=1+activate_kw.get('priority', 1))
kw["min_id"] = r[-1].getId() kw["min_id"] = r[-1].getId()
syncml_logger.info("--> calling getAndActivate in activity, min = %s" % syncml_logger.debug("--> calling getAndActivate in activity, min = %s" %
(kw["min_id"],)) (kw["min_id"],))
self.activate(**next_kw).getAndActivate( self.activate(**next_kw).getAndActivate(
...@@ -148,7 +148,7 @@ class SyncMLSubscription(XMLObject): ...@@ -148,7 +148,7 @@ class SyncMLSubscription(XMLObject):
callback_method = getattr(activate(**activate_kw), callback) callback_method = getattr(activate(**activate_kw), callback)
if generated_other_activity: if generated_other_activity:
for i in xrange(0, result_count, packet_size): for i in xrange(0, result_count, packet_size):
syncml_logger.info("-- getAndActivate : recursive call, generating for %s" syncml_logger.debug("-- getAndActivate : recursive call, generating for %s"
% (r[i:i+packet_size],)) % (r[i:i+packet_size],))
callback_method(id_list=r[i:i+packet_size], callback_method(id_list=r[i:i+packet_size],
message_id=message_id_list.pop(), message_id=message_id_list.pop(),
...@@ -157,14 +157,14 @@ class SyncMLSubscription(XMLObject): ...@@ -157,14 +157,14 @@ class SyncMLSubscription(XMLObject):
else: else:
i = 0 i = 0
for i in xrange(0, result_count-packet_size, packet_size): for i in xrange(0, result_count-packet_size, packet_size):
syncml_logger.info("-- getAndActivate : call, generating for %s : %s" % syncml_logger.debug("-- getAndActivate : call, generating for %s : %s" %
(r[i:i+packet_size], activate_kw)) (r[i:i+packet_size], activate_kw))
callback_method(id_list=r[i:i+packet_size], callback_method(id_list=r[i:i+packet_size],
message_id=message_id_list.pop(), message_id=message_id_list.pop(),
activate_kw=activate_kw, activate_kw=activate_kw,
**method_kw) **method_kw)
# Final activity must be executed after all other # Final activity must be executed after all other
syncml_logger.info("---- getAndActivate : final call for %s : %s" %(r[i+packet_size:], activate_kw)) syncml_logger.debug("---- getAndActivate : final call for %s : %s" %(r[i+packet_size:], activate_kw))
callback_method(id_list=r[i+packet_size:], # XXX Has to be unit tested callback_method(id_list=r[i+packet_size:], # XXX Has to be unit tested
# with mock object # with mock object
message_id=message_id_list.pop(), message_id=message_id_list.pop(),
...@@ -428,7 +428,7 @@ class SyncMLSubscription(XMLObject): ...@@ -428,7 +428,7 @@ class SyncMLSubscription(XMLObject):
message_ref=request_message_id) message_ref=request_message_id)
else: # We want to retrieve more data else: # We want to retrieve more data
syncml_logger.info("we need to retrieve more data for %s" % (signature,)) syncml_logger.debug("we need to retrieve more data for %s" % (signature,))
if signature.getValidationState() != 'partial': if signature.getValidationState() != 'partial':
signature.changeToPartial() signature.changeToPartial()
signature.appendPartialData(incoming_data) signature.appendPartialData(incoming_data)
...@@ -481,7 +481,7 @@ class SyncMLSubscription(XMLObject): ...@@ -481,7 +481,7 @@ class SyncMLSubscription(XMLObject):
XXX Comment to be fixed XXX Comment to be fixed
""" """
if not id_list: if not id_list:
syncml_logger.warning("Non optimal call to _getSyncMLData, no id list provided") syncml_logger.warning("Non optimal call to _getSyncMLData, no id list provided : %r" %(id_list))
else: else:
syncml_logger.info("getSyncMLData, id list provided %s" % (id_list,)) syncml_logger.info("getSyncMLData, id list provided %s" % (id_list,))
...@@ -551,7 +551,7 @@ class SyncMLSubscription(XMLObject): ...@@ -551,7 +551,7 @@ class SyncMLSubscription(XMLObject):
syncml_logger.debug("Created a signature %s for gid = %s, path %s" syncml_logger.debug("Created a signature %s for gid = %s, path %s"
% (signature.getPath(), gid, document.getPath())) % (signature.getPath(), gid, document.getPath()))
if len(document_data) > MAX_LEN: if len(document_data) > MAX_LEN:
syncml_logger.info("data too big, sending multiple message") syncml_logger.debug("data too big, sending multiple message")
more_data = True more_data = True
finished = False finished = False
document_data, rest_string = cutXML(document_data, MAX_LEN) document_data, rest_string = cutXML(document_data, MAX_LEN)
...@@ -564,6 +564,8 @@ class SyncMLSubscription(XMLObject): ...@@ -564,6 +564,8 @@ class SyncMLSubscription(XMLObject):
# confirmation that the document was well synchronized # confirmation that the document was well synchronized
signature.setTemporaryData(document_data) signature.setTemporaryData(document_data)
signature.doSync() signature.doSync()
syncml_logger.debug("signature %s is syncing"
% (signature.getRelativeUrl(),))
# Generate the message # Generate the message
syncml_response.addSyncCommand( syncml_response.addSyncCommand(
...@@ -609,6 +611,9 @@ class SyncMLSubscription(XMLObject): ...@@ -609,6 +611,9 @@ class SyncMLSubscription(XMLObject):
# but Diff generator will return no diff for it # but Diff generator will return no diff for it
# in this case, no need to send diff # in this case, no need to send diff
signature.synchronize() signature.synchronize()
syncml_logger.debug("signature %s is synchronized"
% (signature.getRelativeUrl(),))
continue continue
# Split data if necessary # Split data if necessary
...@@ -621,12 +626,18 @@ class SyncMLSubscription(XMLObject): ...@@ -621,12 +626,18 @@ class SyncMLSubscription(XMLObject):
signature.setPartialAction(REPLACE_ACTION) signature.setPartialAction(REPLACE_ACTION)
if signature.getValidationState() != 'partial': if signature.getValidationState() != 'partial':
signature.changeToPartial() signature.changeToPartial()
syncml_logger.debug("signature %s is partial"
% (signature.getRelativeUrl(),))
else: else:
# Store the new representation of the document # Store the new representation of the document
# It will be copy to "data" property once synchronization # It will be copy to "data" property once synchronization
# is confirmed # is confirmed
signature.setTemporaryData(xml_object) signature.setTemporaryData(xml_object)
signature.doSync() signature.doSync()
syncml_logger.debug("signature %s is syncing"
% (signature.getRelativeUrl(),))
# Generate the command # Generate the command
syncml_logger.debug("will send Replace command with %s" syncml_logger.debug("will send Replace command with %s"
...@@ -640,6 +651,8 @@ class SyncMLSubscription(XMLObject): ...@@ -640,6 +651,8 @@ class SyncMLSubscription(XMLObject):
elif signature.getValidationState() != 'synchronized': elif signature.getValidationState() != 'synchronized':
# We should not have this case when we are in CONFLICT_MERGE # We should not have this case when we are in CONFLICT_MERGE
syncml_logger.debug("signature %s is synchronized"
% (signature.getRelativeUrl(),))
signature.synchronize() signature.synchronize()
elif signature.getValidationState() == \ elif signature.getValidationState() == \
...@@ -662,6 +675,8 @@ class SyncMLSubscription(XMLObject): ...@@ -662,6 +675,8 @@ class SyncMLSubscription(XMLObject):
sync_code='conflict_resolved_with_client_command_winning', sync_code='conflict_resolved_with_client_command_winning',
command='Replace') command='Replace')
signature.synchronize() signature.synchronize()
syncml_logger.debug("signature %s is synchronized"
% (signature.getRelativeUrl(),))
elif signature.getValidationState() == 'partial': elif signature.getValidationState() == 'partial':
# Case of partially sent data # Case of partially sent data
xml_string = signature.getPartialData() xml_string = signature.getPartialData()
...@@ -683,6 +698,8 @@ class SyncMLSubscription(XMLObject): ...@@ -683,6 +698,8 @@ class SyncMLSubscription(XMLObject):
if not more_data: if not more_data:
signature.doSync() signature.doSync()
syncml_logger.debug("signature %s is syncing"
% (signature.getRelativeUrl(),))
elif signature.getValidationState() in ('syncing', 'synchronized'): elif signature.getValidationState() in ('syncing', 'synchronized'):
raise ValueError("Must not get signature in %s state here, signature is %s" raise ValueError("Must not get signature in %s state here, signature is %s"
% (signature.getValidationState(), % (signature.getValidationState(),
...@@ -697,7 +714,8 @@ class SyncMLSubscription(XMLObject): ...@@ -697,7 +714,8 @@ class SyncMLSubscription(XMLObject):
syncml_logger.warning("Package is going to be splitted") syncml_logger.warning("Package is going to be splitted")
break break
loop += 1 loop += 1
syncml_logger.debug("_getSyncMLData end with finished %s"
% (finished,))
return finished return finished
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
...@@ -503,6 +503,8 @@ class SynchronizationTool(BaseTool): ...@@ -503,6 +503,8 @@ class SynchronizationTool(BaseTool):
# Send the message in activity to prevent recomputing data in case of # Send the message in activity to prevent recomputing data in case of
# transport failure # transport failure
syncml_logger.info("%s sendDeleteCommand with final tag"
% (subscription.getRelativeUrl()))
subscription.activate(**activate_kw).sendMessage(xml=str(syncml_response)) subscription.activate(**activate_kw).sendMessage(xml=str(syncml_response))
......
...@@ -53,8 +53,8 @@ class AccountERP5IntegrationConduit(TioSafeBaseConduit): ...@@ -53,8 +53,8 @@ class AccountERP5IntegrationConduit(TioSafeBaseConduit):
""" """
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml, 'id') object_id = self.getAttribute(xml, 'id')
if object_id is not None: if True: # object_id is not None:
if sub_object is None: if sub_object is None and object_id:
try: try:
sub_object = object._getOb(object_id) sub_object = object._getOb(object_id)
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
......
...@@ -103,8 +103,8 @@ class AccountingERP5IntegrationConduit(TioSafeBaseConduit): ...@@ -103,8 +103,8 @@ class AccountingERP5IntegrationConduit(TioSafeBaseConduit):
""" """
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml, 'id') object_id = self.getAttribute(xml, 'id')
if object_id is not None: if True: # object_id is not None:
if sub_object is None: if sub_object is None and object_id:
sub_object = object._getOb(object_id, None) sub_object = object._getOb(object_id, None)
if sub_object is None: # If so, it does not exist if sub_object is None: # If so, it does not exist
portal_type = '' portal_type = ''
......
...@@ -163,8 +163,8 @@ class ERP5NodeConduit(TioSafeBaseConduit): ...@@ -163,8 +163,8 @@ class ERP5NodeConduit(TioSafeBaseConduit):
reset_local_roles=0, reset_workflow=0, simulate=0, **kw): reset_local_roles=0, reset_workflow=0, simulate=0, **kw):
""" This is the method calling to create an object. """ """ This is the method calling to create an object. """
# if DEBUG: # if DEBUG:
# LOG("ERP5NodeContuide._createContent", INFO, "xml = %s" %(etree.tostring(xml, pretty_print=True),)) # LOG("ERP5NodeContuide._createContent", INFO, "xml = %s" %(etree.tostring(xml, pretty_print=True),))
if object_id is not None: if True: # object_id is not None:
sub_object = None sub_object = None
if sub_object is None: # If so, it doesn't exist if sub_object is None: # If so, it doesn't exist
# Check if we can find it in module # Check if we can find it in module
...@@ -288,7 +288,6 @@ class ERP5NodeConduit(TioSafeBaseConduit): ...@@ -288,7 +288,6 @@ class ERP5NodeConduit(TioSafeBaseConduit):
reset_workflow=reset_workflow, reset_workflow=reset_workflow,
) )
self.afterCreateMethod(sub_object, **kw) self.afterCreateMethod(sub_object, **kw)
return sub_object return sub_object
......
...@@ -102,8 +102,8 @@ class ERP5PaymentTransactionConduit(TioSafeBaseConduit): ...@@ -102,8 +102,8 @@ class ERP5PaymentTransactionConduit(TioSafeBaseConduit):
""" """
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml, 'id') object_id = self.getAttribute(xml, 'id')
if object_id is not None: if True: #object_id is not None:
if sub_object is None: if sub_object is None and object_id:
try: try:
sub_object = object._getOb(object_id) sub_object = object._getOb(object_id)
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
......
...@@ -51,7 +51,7 @@ class ERP5ResourceConduit(TioSafeBaseConduit): ...@@ -51,7 +51,7 @@ class ERP5ResourceConduit(TioSafeBaseConduit):
""" """
This is the method calling to create an object This is the method calling to create an object
""" """
if object_id is not None: if True: # object_id is not None:
if sub_object is None: if sub_object is None:
sub_object = object._getOb(object_id, None) sub_object = object._getOb(object_id, None)
if sub_object is None: # If so, it does not exist if sub_object is None: # If so, it does not exist
......
...@@ -60,8 +60,8 @@ class ERP5TransactionConduit(TioSafeBaseConduit): ...@@ -60,8 +60,8 @@ class ERP5TransactionConduit(TioSafeBaseConduit):
""" """
if object_id is None: if object_id is None:
object_id = self.getAttribute(xml, 'id') object_id = self.getAttribute(xml, 'id')
if object_id is not None: if True: # object_id is not None:
if sub_object is None: if sub_object is None and object_id:
try: try:
sub_object = object._getOb(object_id) sub_object = object._getOb(object_id)
except (AttributeError, KeyError, TypeError): except (AttributeError, KeyError, TypeError):
......
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