Commit 3e4039c5 authored by Aurel's avatar Aurel

object_id is no longer provided by synchronization tool

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