Commit 6f2372aa authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Migrate ERP5SyncML Product from filesystem.

To avoid too generic names for Products.ERP5SyncML.{Engine,Transport}, prefix
the ZODB Components references with SyncML{Engine,Transport}.
parent c8ad77fb
Pipeline #10251 failed with stage
...@@ -65,7 +65,7 @@ def findMessageListFromPythonInProduct(function_name_list): ...@@ -65,7 +65,7 @@ def findMessageListFromPythonInProduct(function_name_list):
erp5_product_list = ('CMFActivity', 'CMFCategory', erp5_product_list = ('CMFActivity', 'CMFCategory',
'ERP5', 'ERP5Banking', 'ERP5Catalog', 'ERP5', 'ERP5Banking', 'ERP5Catalog',
'ERP5Form', 'ERP5OOo', 'ERP5Security', 'ERP5Form', 'ERP5OOo', 'ERP5Security',
'ERP5SyncML', 'ERP5Type', 'ERP5Wizard', 'ERP5Workflow', 'ERP5Type', 'ERP5Wizard', 'ERP5Workflow',
'HBTreeFolder2', 'MailTemplates', 'TimerService', 'HBTreeFolder2', 'MailTemplates', 'TimerService',
'ZMySQLDA', 'ZSQLCatalog', 'ZMySQLDA', 'ZSQLCatalog',
) )
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLConflict</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Document.SyncMLConflict</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.SyncMLConflict</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
# #
############################################################################## ##############################################################################
from Products.ERP5SyncML.Document.SyncMLSubscription import SyncMLSubscription from erp5.component.document.SyncMLSubscription import SyncMLSubscription
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5SyncML.SyncMLConstant import ACTIVITY_PRIORITY from erp5.component.module.SyncMLConstant import ACTIVITY_PRIORITY
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class SyncMLPublication(SyncMLSubscription): class SyncMLPublication(SyncMLSubscription):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLPublication</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Document.SyncMLPublication</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.SyncMLPublication</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -34,11 +34,11 @@ from AccessControl import ClassSecurityInfo ...@@ -34,11 +34,11 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
from Products.ERP5SyncML.Utils import PdataHelper from erp5.component.module.SyncMLUtils import PdataHelper
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
_MARKER = [] _MARKER = object()
class SyncMLSignature(XMLObject): class SyncMLSignature(XMLObject):
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLSignature</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Document.SyncMLSignature</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.SyncMLSignature</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLSubscription</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Document.SyncMLSubscription</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.SyncMLSubscription</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -67,7 +67,7 @@ class IConduit(Interface): ...@@ -67,7 +67,7 @@ class IConduit(Interface):
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""" """
def constructContent(object, object_id, portal_type): def constructContent(object, object_id, portal_type): # pylint: disable=redefined-builtin
""" """
This allows to specify how to construct a new content. This allows to specify how to construct a new content.
This is really usefull if you want to write your This is really usefull if you want to write your
...@@ -82,7 +82,7 @@ class IConduit(Interface): ...@@ -82,7 +82,7 @@ class IConduit(Interface):
return newObject, reset_local_roles boolean, reset_workflow boolean return newObject, reset_local_roles boolean, reset_workflow boolean
""" """
def addNode(xml=None, object=None, previous_xml=None, def addNode(xml=None, object=None, previous_xml=None, # pylint: disable=redefined-builtin
object_id=None, sub_object=None, force=0, simulate=0, **kw): object_id=None, sub_object=None, force=0, simulate=0, **kw):
""" """
A node is added A node is added
...@@ -100,13 +100,13 @@ class IConduit(Interface): ...@@ -100,13 +100,13 @@ class IConduit(Interface):
[object.getPath(),keyword,local_and_actual_value,subscriber_value] [object.getPath(),keyword,local_and_actual_value,subscriber_value]
""" """
def deleteNode(xml=None, object=None, object_id=None, force=None, def deleteNode(xml=None, object=None, object_id=None, force=None, # pylint: disable=redefined-builtin
simulate=0, **kw): simulate=0, **kw):
""" """
A node is deleted A node is deleted
""" """
def updateNode(xml=None, object=None, previous_xml=None, force=0, def updateNode(xml=None, object=None, previous_xml=None, force=0, # pylint: disable=redefined-builtin
simulate=0, **kw): simulate=0, **kw):
""" """
A node is updated with some xupdate A node is updated with some xupdate
...@@ -117,7 +117,7 @@ class IConduit(Interface): ...@@ -117,7 +117,7 @@ class IConduit(Interface):
""" """
def getGidFromObject(object, configurable_gid_dictionary=None): def getGidFromObject(object, configurable_gid_dictionary=None): # pylint: disable=redefined-builtin
""" """
return the Gid composed with the object information return the Gid composed with the object information
- object is the document on which for we are building the gid. - object is the document on which for we are building the gid.
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interface Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>IConduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.interfaces.conduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interface.erp5.IConduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interface Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -31,15 +31,15 @@ from AccessControl import ClassSecurityInfo, getSecurityManager ...@@ -31,15 +31,15 @@ from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.PluggableAuthService.interfaces.plugins import \ from Products.PluggableAuthService.interfaces.plugins import \
IAuthenticationPlugin IAuthenticationPlugin
from Products.ERP5SyncML.XMLSyncUtils import resolveSyncmlStatusCode, decode from erp5.component.module.XMLSyncUtils import resolveSyncmlStatusCode, decode
from Products.ERP5SyncML.SyncMLMessage import SyncMLResponse from erp5.component.module.SyncMLMessage import SyncMLResponse
from Products.ERP5SyncML.SyncMLConstant import NULL_ANCHOR, ACTIVITY_PRIORITY, \ from erp5.component.module.SyncMLConstant import NULL_ANCHOR, ACTIVITY_PRIORITY, \
SynchronizationError SynchronizationError
syncml_logger = getLogger('ERP5SyncML') syncml_logger = getLogger('ERP5SyncML')
class EngineMixin(object): class SyncMLEngineMixin(object):
""" """
Mixin class that holds generci methods used by engines Mixin class that holds generci methods used by engines
""" """
...@@ -75,9 +75,11 @@ class EngineMixin(object): ...@@ -75,9 +75,11 @@ class EngineMixin(object):
status['authentication_type'])) status['authentication_type']))
# XXX Not working To Review ! # XXX Not working To Review !
raise NotImplementedError("Adding credentials") raise NotImplementedError("Adding credentials")
"""
syncml_response = domain.generateBaseResponse() syncml_response = domain.generateBaseResponse()
syncml_response.addCredentialMessage(domain) syncml_response.addCredentialMessage(domain)
return syncml_response return syncml_response
"""
elif status['status_code'] == \ elif status['status_code'] == \
resolveSyncmlStatusCode('invalid_credentials'): resolveSyncmlStatusCode('invalid_credentials'):
syncml_logger.error("\tClient authentication refused") syncml_logger.error("\tClient authentication refused")
...@@ -92,8 +94,8 @@ class EngineMixin(object): ...@@ -92,8 +94,8 @@ class EngineMixin(object):
# XXX Must check status for asked synchrozation # XXX Must check status for asked synchrozation
# and must be done for command, not for # and must be done for command, not for
# For now do nothing = say it is always OK # For now do nothing = say it is always OK
syncml_logger.info("\tChecking database, will generate alert %s" syncml_logger.info("\tChecking database, will generate alert %s",
% (generate_alert)) generate_alert)
elif status["command"] in ('Add', 'Replace'): elif status["command"] in ('Add', 'Replace'):
sync_status_counter += 1 sync_status_counter += 1
object_gid = status['source'] or status['target'] object_gid = status['source'] or status['target']
...@@ -110,27 +112,27 @@ class EngineMixin(object): ...@@ -110,27 +112,27 @@ class EngineMixin(object):
% (domain.getPath(), object_gid)) % (domain.getPath(), object_gid))
if status['status_code'] == resolveSyncmlStatusCode('conflict'): if status['status_code'] == resolveSyncmlStatusCode('conflict'):
signature.changeToConflict() signature.changeToConflict()
syncml_logger.error("\tObject in conflict %s" % syncml_logger.error("\tObject in conflict %s",
(status['source'] or status['target'])) status['source'] or status['target'])
elif status['status_code'] == resolveSyncmlStatusCode( elif status['status_code'] == resolveSyncmlStatusCode(
'conflict_resolved_with_merge'): 'conflict_resolved_with_merge'):
# We will have to apply the update, and we should not care # We will have to apply the update, and we should not care
# about conflicts, so we have to force the update # about conflicts, so we have to force the update
signature.noConflict() signature.noConflict()
signature.setForce(True) signature.setForce(True)
syncml_logger.error("\tObject merged %s" % syncml_logger.error("\tObject merged %s",
(status['source'] or status['target'])) status['source'] or status['target'])
elif status['status_code'] in (resolveSyncmlStatusCode('success'), elif status['status_code'] in (resolveSyncmlStatusCode('success'),
resolveSyncmlStatusCode('item_added'), resolveSyncmlStatusCode('item_added'),
resolveSyncmlStatusCode( resolveSyncmlStatusCode(
'conflict_resolved_with_client_command_winning')): 'conflict_resolved_with_client_command_winning')):
syncml_logger.error("\tObject synchronized %s" % syncml_logger.error("\tObject synchronized %s",
(status['source'] or status['target'],)) status['source'] or status['target'])
if signature.getValidationState() != "no_conflict": if signature.getValidationState() != "no_conflict":
signature.noConflict() signature.noConflict()
signature.synchronize() signature.synchronize()
elif status['status_code'] == resolveSyncmlStatusCode('chunk_accepted'): elif status['status_code'] == resolveSyncmlStatusCode('chunk_accepted'):
syncml_logger.info("Chunk was accepted for %s" % (object_gid,)) syncml_logger.info("Chunk was accepted for %s", object_gid)
else: else:
raise ValueError("Unknown status code : %r" % (status['status_code'],)) raise ValueError("Unknown status code : %r" % (status['status_code'],))
# Index signature now to fill the data column # Index signature now to fill the data column
...@@ -147,8 +149,8 @@ class EngineMixin(object): ...@@ -147,8 +149,8 @@ class EngineMixin(object):
raise ValueError("Found no signature to delete for gid %s" %(object_gid,)) raise ValueError("Found no signature to delete for gid %s" %(object_gid,))
else: else:
raise ValueError("Unknown status code : %r" % (status['status_code'],)) raise ValueError("Unknown status code : %r" % (status['status_code'],))
syncml_logger.error("\tObject deleted %s" % syncml_logger.error("\tObject deleted %s",
(status['source'] or status['target'])) status['source'] or status['target'])
else: else:
raise ValueError("Unknown status command : %r" % (status['command'],)) raise ValueError("Unknown status command : %r" % (status['command'],))
...@@ -174,8 +176,8 @@ class EngineMixin(object): ...@@ -174,8 +176,8 @@ class EngineMixin(object):
done here but can be a way of improvement to decrease number of messages done here but can be a way of improvement to decrease number of messages
exchanged. exchanged.
""" """
syncml_logger.info('--- Starting synchronization on client side : %s ---' syncml_logger.info('--- Starting synchronization on client side : %s ---',
% (subscription.getPath(),)) subscription.getPath())
if not subscription.getSynchronizationState() == "initializing": if not subscription.getSynchronizationState() == "initializing":
# This can be called many time in sync init when credentials failed # This can be called many time in sync init when credentials failed
subscription.initialize() # Worflow action subscription.initialize() # Worflow action
...@@ -309,8 +311,8 @@ class EngineMixin(object): ...@@ -309,8 +311,8 @@ class EngineMixin(object):
% syncml_request.alert['data']) % syncml_request.alert['data'])
syncml_logger.info('--- Starting synchronization on server side : %s in mode %s ---' syncml_logger.info('--- Starting synchronization on server side : %s in mode %s ---',
% (publication.getPath(), alert_dict["data"])) publication.getPath(), alert_dict["data"])
# at the begining of the synchronization the subscriber is not authenticated # at the begining of the synchronization the subscriber is not authenticated
if subscriber.getAuthenticationState() == 'logged_in': if subscriber.getAuthenticationState() == 'logged_in':
subscriber.logout() subscriber.logout()
...@@ -339,13 +341,13 @@ class EngineMixin(object): ...@@ -339,13 +341,13 @@ class EngineMixin(object):
login, password = decoded.split(':') login, password = decoded.split(':')
# TODO: make it work for users existing anywhere # TODO: make it work for users existing anywhere
user_folder = publication.getPortalObject().acl_users user_folder = publication.getPortalObject().acl_users
for plugin_name, plugin in user_folder._getOb('plugins')\ for _, plugin in user_folder._getOb('plugins')\
.listPlugins(IAuthenticationPlugin): .listPlugins(IAuthenticationPlugin):
if plugin.authenticateCredentials( if plugin.authenticateCredentials(
{'login': login, 'password': password}) is not None: {'login': login, 'password': password}) is not None:
subscriber.login() subscriber.login()
syncml_logger.info("\tServer accepted authentication for user %s" syncml_logger.info("\tServer accepted authentication for user %s",
% (login,)) login)
authentication_code = 'authentication_accepted' authentication_code = 'authentication_accepted'
subscriber._loginUser(login) subscriber._loginUser(login)
subscriber._edit(authenticated_user=login) subscriber._edit(authenticated_user=login)
...@@ -356,21 +358,21 @@ class EngineMixin(object): ...@@ -356,21 +358,21 @@ class EngineMixin(object):
# authentication_code = 'missing_credentials' # authentication_code = 'missing_credentials'
# else: # else:
authentication_code = 'invalid_credentials' authentication_code = 'invalid_credentials'
syncml_logger.error("\tServer rejected authentication for %s" % (login)) syncml_logger.error("\tServer rejected authentication for %s", login)
else: else:
# if header_kw["message_id"] == 1: # if header_kw["message_id"] == 1:
# authentication_code = 'missing_credentials' # authentication_code = 'missing_credentials'
# else: # else:
authentication_code = 'invalid_credentials' authentication_code = 'invalid_credentials'
syncml_logger.warning( syncml_logger.warning(
"\tCredentials does not look like auth-basis, decoded value is '%s,'" "\tCredentials does not look like auth-basis, decoded value is '%s,'",
% (decoded)) decoded)
else: else:
# To complete, must send a challenge message # To complete, must send a challenge message
syncml_logger.warning( syncml_logger.warning(
"\tAuthentication type does not math, from client '%s', from server '%s'" %( "\tAuthentication type does not math, from client '%s', from server '%s'",
syncml_request.credentials['type'], syncml_request.credentials['type'],
publication.getAuthenticationType())) publication.getAuthenticationType())
authentication_code = 'missing_credentials' authentication_code = 'missing_credentials'
...@@ -397,9 +399,9 @@ class EngineMixin(object): ...@@ -397,9 +399,9 @@ class EngineMixin(object):
elif subscriber.getNextAnchor() != alert_dict['last_anchor']: elif subscriber.getNextAnchor() != alert_dict['last_anchor']:
# Anchor does not match, must start a slow sync # Anchor does not match, must start a slow sync
syncml_logger.warning("\tAnchor does not match on server, \ syncml_logger.warning("\tAnchor does not match on server, \
received is %s, stored %s. Will start a slow sync" received is %s, stored %s. Will start a slow sync",
%(alert_dict['last_anchor'], alert_dict['last_anchor'],
subscriber.getNextAnchor())) subscriber.getNextAnchor())
sync_type_validation_code = "command_failed" # Error 500 sync_type_validation_code = "command_failed" # Error 500
sync_type = 'slow_sync' sync_type = 'slow_sync'
else: else:
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Mixin Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLEngineMixin</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Engine.EngineMixin</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>mixin.erp5.SyncMLEngineMixin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Mixin Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -42,7 +42,7 @@ class BaseConduit(object): ...@@ -42,7 +42,7 @@ class BaseConduit(object):
def generateDiff(self, new_data, former_data): def generateDiff(self, new_data, former_data):
return None return None
def getXMLFromObjectWithId(self, object, xml_mapping, context_document=None): def getXMLFromObjectWithId(self, object, xml_mapping, context_document=None): # pylint: disable=redefined-builtin
""" """
return the xml with Id of Object return the xml with Id of Object
""" """
...@@ -60,7 +60,7 @@ class BaseConduit(object): ...@@ -60,7 +60,7 @@ class BaseConduit(object):
return data return data
def getGidFromObject(self, object): def getGidFromObject(self, object): # pylint: disable=redefined-builtin
""" """
return the Gid composed with the object informations return the Gid composed with the object informations
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>BaseConduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.BaseConduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.BaseConduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ERP5Conduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.ERP5Conduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.ERP5Conduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from erp5.component.module.ERP5Conduit import ERP5Conduit
class ERP5ConduitTitleGid(ERP5Conduit): class ERP5ConduitTitleGid(ERP5Conduit):
...@@ -42,7 +42,7 @@ class ERP5ConduitTitleGid(ERP5Conduit): ...@@ -42,7 +42,7 @@ class ERP5ConduitTitleGid(ERP5Conduit):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
def getGidFromObject(self, object): def getGidFromObject(self, object): # pylint: disable=redefined-builtin
""" """
return the Gid composed of FirstName and LastName generate with the object return the Gid composed of FirstName and LastName generate with the object
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ERP5ConduitTitleGid</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.ERP5ConduitTitleGid</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.ERP5ConduitTitleGid</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from erp5.component.module.ERP5Conduit import ERP5Conduit
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -49,7 +49,7 @@ class ERP5DocumentConduit(ERP5Conduit): ...@@ -49,7 +49,7 @@ class ERP5DocumentConduit(ERP5Conduit):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareProtected(Permissions.AccessContentsInformation, 'getGidFromObject') security.declareProtected(Permissions.AccessContentsInformation, 'getGidFromObject')
def getGidFromObject(self, object): def getGidFromObject(self, object): # pylint: disable=redefined-builtin
""" """
return the Gid generate with the reference, object, language of the object return the Gid generate with the reference, object, language of the object
""" """
...@@ -70,7 +70,6 @@ class ERP5DocumentConduit(ERP5Conduit): ...@@ -70,7 +70,6 @@ class ERP5DocumentConduit(ERP5Conduit):
else: else:
return WORKFLOW_ACTION_ADDABLE return WORKFLOW_ACTION_ADDABLE
addable = WORKFLOW_ACTION_ADDABLE addable = WORKFLOW_ACTION_ADDABLE
time = status.get('time')
for action in action_list: for action in action_list:
this_one = WORKFLOW_ACTION_ADDABLE this_one = WORKFLOW_ACTION_ADDABLE
# if time <= action.get('time'): # if time <= action.get('time'):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ERP5DocumentConduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.ERP5DocumentConduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.ERP5DocumentConduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -34,7 +34,7 @@ from cStringIO import StringIO ...@@ -34,7 +34,7 @@ from cStringIO import StringIO
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from zLOG import LOG from zLOG import LOG
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from erp5.component.module.ERP5Conduit import ERP5Conduit
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
...@@ -53,12 +53,11 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -53,12 +53,11 @@ class ERP5ShopOrderConduit(ERP5Conduit):
random.seed() random.seed()
security.declareProtected(Permissions.ModifyPortalContent, 'constructContent') security.declareProtected(Permissions.ModifyPortalContent, 'constructContent')
def constructContent(self, object, object_id, docid, portal_type): def constructContent(self, object, object_id, docid, portal_type): # pylint: disable=redefined-builtin,arguments-differ
""" """
This is a redefinition of the original ERP5Conduit.constructContent function to This is a redefinition of the original ERP5Conduit.constructContent function to
allow the creation of a ERP5 Sale Order instead of a Storever Shop Order. allow the creation of a ERP5 Sale Order instead of a Storever Shop Order.
""" """
portal_types = getToolByName(object, 'portal_types')
subobject = None subobject = None
new_object_id = object_id new_object_id = object_id
if portal_type == 'Shop Order': if portal_type == 'Shop Order':
...@@ -283,7 +282,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -283,7 +282,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
security.declarePrivate('updateObjProperty') security.declarePrivate('updateObjProperty')
def updateObjProperty(self, object, property, kw, key): def updateObjProperty(self, object, property, kw, key): # pylint: disable=redefined-builtin
""" """
This function update the property of an object with a given value stored in a dictionnary. This function help the Conduit to make decision about the synchronization of values. This function update the property of an object with a given value stored in a dictionnary. This function help the Conduit to make decision about the synchronization of values.
...@@ -296,10 +295,10 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -296,10 +295,10 @@ class ERP5ShopOrderConduit(ERP5Conduit):
if kw.has_key(key): if kw.has_key(key):
new_value = kw[key] new_value = kw[key]
if new_value != None: if new_value != None:
if type(new_value) is type('s'): if isinstance(new_value, str):
new_value = new_value.title() new_value = new_value.title()
current_value = eval('object.get' + property + '()') current_value = getattr(object, 'get' + property)()
LOG("I have to run this >>>>>>>> ", 0, 'object.get' + property + '()') LOG("I have to run this >>>>>>>> ", 0, 'object.get' + property + '()')
LOG("current_value >>>>>>>> ", 0, repr(current_value)) LOG("current_value >>>>>>>> ", 0, repr(current_value))
...@@ -320,7 +319,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -320,7 +319,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
security.declareProtected(Permissions.ModifyPortalContent, 'editDocument') security.declareProtected(Permissions.ModifyPortalContent, 'editDocument')
def editDocument(self, object=None, **kw): def editDocument(self, object=None, **kw): # pylint: disable=redefined-builtin
""" """
This function use the properties of the object to convert a Storever ShopOrder to an ERP5 SaleOrder. This function use the properties of the object to convert a Storever ShopOrder to an ERP5 SaleOrder.
""" """
...@@ -478,7 +477,6 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -478,7 +477,6 @@ class ERP5ShopOrderConduit(ERP5Conduit):
# We only need to be aware of data fusion between the previous and the current representation # We only need to be aware of data fusion between the previous and the current representation
# So we don't need to do something because the information fusion process take place below # So we don't need to do something because the information fusion process take place below
LOG("The structure is the same. don't do anything >>>>>>>>",0,'') LOG("The structure is the same. don't do anything >>>>>>>>",0,'')
pass
LOG("Person object >>>>>>>>",0,repr(person_object)) LOG("Person object >>>>>>>>",0,repr(person_object))
LOG("Organisation object >>>>>>>>",0,repr(org_object)) LOG("Organisation object >>>>>>>>",0,repr(org_object))
...@@ -628,9 +626,9 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -628,9 +626,9 @@ class ERP5ShopOrderConduit(ERP5Conduit):
erp5_ship_id_word_list = self.str2id(service_id).split("_") erp5_ship_id_word_list = self.str2id(service_id).split("_")
stor_ship_id_word_list = self.str2id(stor_ship_title).split("_") stor_ship_id_word_list = self.str2id(stor_ship_title).split("_")
erp5_ship_title_word_list = self.str2id(erp5_ship_title).split("_") erp5_ship_title_word_list = self.str2id(erp5_ship_title).split("_")
erp5_ship_id_word_list.sort(key=lambda x: str(x)) erp5_ship_id_word_list.sort(key=str)
stor_ship_id_word_list.sort(key=lambda x: str(x)) stor_ship_id_word_list.sort(key=str)
erp5_ship_title_word_list.sort(key=lambda x: str(x)) erp5_ship_title_word_list.sort(key=str)
if stor_ship_id_word_list in (erp5_ship_id_word_list, erp5_ship_title_word_list): if stor_ship_id_word_list in (erp5_ship_id_word_list, erp5_ship_title_word_list):
shipment_id = service_id shipment_id = service_id
LOG("Service found with method 3 ! >>>>>>>>", 0, repr(shipment_id)) LOG("Service found with method 3 ! >>>>>>>>", 0, repr(shipment_id))
...@@ -676,8 +674,6 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -676,8 +674,6 @@ class ERP5ShopOrderConduit(ERP5Conduit):
# The object is an OrderLine # The object is an OrderLine
else: else:
# Find the product folder # Find the product folder
product_path = erp5_site_path + '/product'
product_folder = erp5_site.restrictedTraverse(product_path)
# Find the parent order object # Find the parent order object
parent_order_object = object.aq_parent parent_order_object = object.aq_parent
...@@ -787,7 +783,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -787,7 +783,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
LOG('editDocument, cat_base',0,cat_base) LOG('editDocument, cat_base',0,cat_base)
base_cat_object = portal_cat.resolveCategory(cat_base) base_cat_object = portal_cat.resolveCategory(cat_base)
cat_list = base_cat_object.getCategoryChildIdItemList() cat_list = base_cat_object.getCategoryChildIdItemList()
for (category, category_bis) in cat_list: for (category, _) in cat_list:
if self.str2id(option) == category: if self.str2id(option) == category:
customer_product_variation_list[category] = cat_base + '/' + category customer_product_variation_list[category] = cat_base + '/' + category
if cat_base not in customer_product_base_variation_list: if cat_base not in customer_product_base_variation_list:
...@@ -799,7 +795,7 @@ class ERP5ShopOrderConduit(ERP5Conduit): ...@@ -799,7 +795,7 @@ class ERP5ShopOrderConduit(ERP5Conduit):
if option_is_variant == None: if option_is_variant == None:
customer_product_option_list[option] = priced_list[option] customer_product_option_list[option] = priced_list[option]
if len(customer_product_option_list) + len(customer_product_variation_list) != len(priced_list): if len(customer_product_option_list) + len(customer_product_variation_list) != len(priced_list):
LOG('>>>>>>> Wrong repartition of the customer priced list', 200) LOG('>>>>>>> Wrong repartition of the customer priced list', 200, '')
LOG('>>>>>> Customer product option priced list: ', 0, repr(customer_product_option_list)) LOG('>>>>>> Customer product option priced list: ', 0, repr(customer_product_option_list))
LOG('>>>>>> Customer product variation priced list: ', 0, repr(customer_product_variation_list)) LOG('>>>>>> Customer product variation priced list: ', 0, repr(customer_product_variation_list))
LOG('>>>>>> Customer product base variation list: ', 0, repr(customer_product_base_variation_list)) LOG('>>>>>> Customer product base variation list: ', 0, repr(customer_product_base_variation_list))
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ERP5ShopOrderConduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.ERP5ShopOrderConduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.ERP5ShopOrderConduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5SyncML.Conduit.VCardConduit import VCardConduit from erp5.component.module.VCardConduit import VCardConduit
# pylint: disable=abstract-method
class SharedVCardConduit(VCardConduit): class SharedVCardConduit(VCardConduit):
""" """
A conduit is in charge to read data from a particular structure, A conduit is in charge to read data from a particular structure,
...@@ -45,7 +45,7 @@ class SharedVCardConduit(VCardConduit): ...@@ -45,7 +45,7 @@ class SharedVCardConduit(VCardConduit):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
def getGidFromObject(self, object): def getGidFromObject(self, object): # pylint: disable=redefined-builtin
""" """
return the Gid composed of FirstName_LastName generate with the object return the Gid composed of FirstName_LastName generate with the object
""" """
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SharedVCardConduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.SharedVCardConduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SharedVCardConduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,4 +50,4 @@ REPLACE_ACTION = 'Replace' ...@@ -50,4 +50,4 @@ REPLACE_ACTION = 'Replace'
ACTIVITY_PRIORITY = 5 ACTIVITY_PRIORITY = 5
class SynchronizationError(Exception): class SynchronizationError(Exception):
pass pass
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLConstant</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.SyncMLConstant</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLConstant</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,31 +27,31 @@ ...@@ -27,31 +27,31 @@
from logging import getLogger from logging import getLogger
from Products.ERP5SyncML.Engine.EngineMixin import EngineMixin from erp5.component.mixin.SyncMLEngineMixin import SyncMLEngineMixin
from Products.ERP5SyncML.SyncMLConstant import ACTIVITY_PRIORITY from erp5.component.module.SyncMLConstant import ACTIVITY_PRIORITY
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
syncml_logger = getLogger('ERP5SyncML') syncml_logger = getLogger('ERP5SyncML')
class SyncMLAsynchronousEngine(EngineMixin): class SyncMLAsynchronousEngine(SyncMLEngineMixin):
""" Implement synchronization engine using activities """ """ Implement synchronization engine using activities """
def processClientSynchronization(self, syncml_request, subscription): def processClientSynchronization(self, syncml_request, subscription):
""" Global method that process the package 3, 4 & 5 of SyncML DS Protocol """ """ Global method that process the package 3, 4 & 5 of SyncML DS Protocol """
syncml_logger.info("xxx Client processing data from server (%s) xxx" syncml_logger.info("xxx Client processing data from server (%s) xxx",
% (subscription.getSynchronizationState())) subscription.getSynchronizationState())
syncml_logger.info("\tstatus %s, sync %s, final %s" syncml_logger.info("\tstatus %s, sync %s, final %s",
% (len(syncml_request.status_list), len(syncml_request.status_list),
len(syncml_request.sync_command_list), len(syncml_request.sync_command_list),
syncml_request.isFinal)) syncml_request.isFinal)
# We must log in with user defined # We must log in with user defined
subscription._loginUser() subscription._loginUser()
if syncml_request.alert_list: if syncml_request.alert_list:
syncml_logger.warning("Got an alert from server not processed : %s" syncml_logger.warning("Got an alert from server not processed : %s",
% (syncml_request.alert_list,)) syncml_request.alert_list)
# Must check what server tell about database synchronization # Must check what server tell about database synchronization
# and update the mode if required # and update the mode if required
...@@ -98,8 +98,8 @@ class SyncMLAsynchronousEngine(EngineMixin): ...@@ -98,8 +98,8 @@ class SyncMLAsynchronousEngine(EngineMixin):
self.runApplySyncCommand(subscription=subscription, self.runApplySyncCommand(subscription=subscription,
syncml_request=syncml_request, syncml_request=syncml_request,
tag=tag) tag=tag)
syncml_logger.info("-> Client apply command in %d activities" syncml_logger.info("-> Client apply command in %d activities",
% (len(syncml_request.sync_command_list))) len(syncml_request.sync_command_list))
if syncml_request.isFinal: if syncml_request.isFinal:
if not syncml_response: if not syncml_response:
syncml_response = subscription.generateBaseResponse() syncml_response = subscription.generateBaseResponse()
...@@ -153,10 +153,10 @@ class SyncMLAsynchronousEngine(EngineMixin): ...@@ -153,10 +153,10 @@ class SyncMLAsynchronousEngine(EngineMixin):
# syncml_response = subscriber.getLastSentMessage("") # XXX # syncml_response = subscriber.getLastSentMessage("") # XXX
else: else:
syncml_logger.info("xxx Server processing data from client xxx") syncml_logger.info("xxx Server processing data from client xxx")
syncml_logger.info("\tstatus %s, sync %s, final %s" syncml_logger.info("\tstatus %s, sync %s, final %s",
% (len(syncml_request.status_list), len(syncml_request.status_list),
len(syncml_request.sync_command_list), len(syncml_request.sync_command_list),
syncml_request.isFinal)) syncml_request.isFinal)
# we log the user authenticated to do the synchronization with him # we log the user authenticated to do the synchronization with him
if subscriber.getAuthenticationState() == 'logged_in': if subscriber.getAuthenticationState() == 'logged_in':
subscriber._loginUser() subscriber._loginUser()
...@@ -200,8 +200,8 @@ class SyncMLAsynchronousEngine(EngineMixin): ...@@ -200,8 +200,8 @@ class SyncMLAsynchronousEngine(EngineMixin):
# First server process sync commands : Pkg 3 of the sync process # First server process sync commands : Pkg 3 of the sync process
self.runApplySyncCommand(subscription=subscriber, self.runApplySyncCommand(subscription=subscriber,
syncml_request=syncml_request, tag=tag) syncml_request=syncml_request, tag=tag)
syncml_logger.info("-> Server apply command in %d activities" syncml_logger.info("-> Server apply command in %d activities",
% (len(syncml_request.sync_command_list))) len(syncml_request.sync_command_list))
if syncml_request.isFinal: if syncml_request.isFinal:
# Server then sends its modifications # Server then sends its modifications
subscriber.sendModifications() subscriber.sendModifications()
...@@ -226,7 +226,7 @@ class SyncMLAsynchronousEngine(EngineMixin): ...@@ -226,7 +226,7 @@ class SyncMLAsynchronousEngine(EngineMixin):
activity_created = self.runGetAndActivate(subscription=subscriber, activity_created = self.runGetAndActivate(subscription=subscriber,
after_method_id=after_method_id, after_method_id=after_method_id,
tag=tag) tag=tag)
syncml_logger.info("X--> Server is sending modifications in activities %s" %(activity_created)) syncml_logger.info("X--> Server is sending modifications in activities %s", activity_created)
if not activity_created: if not activity_created:
# Server has no modification to send to client, return final message # Server has no modification to send to client, return final message
syncml_logger.info("X-> Server sending final message") syncml_logger.info("X-> Server sending final message")
...@@ -281,7 +281,7 @@ class SyncMLAsynchronousEngine(EngineMixin): ...@@ -281,7 +281,7 @@ class SyncMLAsynchronousEngine(EngineMixin):
id_count=len(syncml_request.sync_command_list)) id_count=len(syncml_request.sync_command_list))
response_id_list.reverse() response_id_list.reverse()
else: else:
response_id_list = [None for x in response_id_list = [None for _ in
xrange(len(syncml_request.sync_command_list))] xrange(len(syncml_request.sync_command_list))]
split = getSite().portal_preferences.getPreferredSyncActionPerActivityCount() split = getSite().portal_preferences.getPreferredSyncActionPerActivityCount()
if not split: # We do not use activities if not split: # We do not use activities
...@@ -306,7 +306,7 @@ class SyncMLAsynchronousEngine(EngineMixin): ...@@ -306,7 +306,7 @@ class SyncMLAsynchronousEngine(EngineMixin):
"group_method_cost" : 1./float(split), "group_method_cost" : 1./float(split),
} }
for action in syncml_request.sync_command_list: for action in syncml_request.sync_command_list:
syncml_logger.info("---> launch action in activity %s" %(action,)) syncml_logger.info("---> launch action in activity %s", action)
activate(**activate_kw).applySyncCommand( activate(**activate_kw).applySyncCommand(
response_message_id=response_id_list.pop(), response_message_id=response_id_list.pop(),
activate_kw=activate_kw, activate_kw=activate_kw,
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLEngineAsynchronous</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Engine.AsynchronousEngine</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLEngineAsynchronous</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
from logging import getLogger from logging import getLogger
from Products.ERP5SyncML.Engine.EngineMixin import EngineMixin from erp5.component.mixin.SyncMLEngineMixin import SyncMLEngineMixin
from Products.ERP5SyncML.SyncMLConstant import SynchronizationError from erp5.component.module.SyncMLConstant import SynchronizationError
syncml_logger = getLogger('ERP5SyncML') syncml_logger = getLogger('ERP5SyncML')
class SyncMLSynchronousEngine(EngineMixin): class SyncMLSynchronousEngine(SyncMLEngineMixin):
""" """
Implement a synchronous engine wait for IO Implement a synchronous engine wait for IO
""" """
...@@ -41,16 +41,16 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -41,16 +41,16 @@ class SyncMLSynchronousEngine(EngineMixin):
""" Global method that process the package 3 of SyncML DS Protocol """ """ Global method that process the package 3 of SyncML DS Protocol """
syncml_logger.info("xxx Client processing data from server xxx") syncml_logger.info("xxx Client processing data from server xxx")
syncml_logger.info("\tstatus %s, sync %s, final %s" syncml_logger.info("\tstatus %s, sync %s, final %s",
% (len(syncml_request.status_list), len(syncml_request.status_list),
len(syncml_request.sync_command_list), len(syncml_request.sync_command_list),
syncml_request.isFinal)) syncml_request.isFinal)
# Process sync logged in # Process sync logged in
subscription._loginUser() subscription._loginUser()
if syncml_request.alert_list: if syncml_request.alert_list:
syncml_logger.warning("Got an alert from server not processed : %s" syncml_logger.warning("Got an alert from server not processed : %s",
% (syncml_request.alert_list,)) syncml_request.alert_list)
# Must check what server tell about database synchronization # Must check what server tell about database synchronization
# and update the mode if required # and update the mode if required
...@@ -61,8 +61,8 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -61,8 +61,8 @@ class SyncMLSynchronousEngine(EngineMixin):
self._readStatusList(syncml_request, subscription, syncml_response) self._readStatusList(syncml_request, subscription, syncml_response)
except SynchronizationError: except SynchronizationError:
# Looks like we process an already received message # Looks like we process an already received message
syncml_logger.error("%s does no process packet due to error" syncml_logger.error("%s does no process packet due to error",
% (subscription.getRelativeUrl())) subscription.getRelativeUrl())
return return
if syncml_request.isFinal and \ if syncml_request.isFinal and \
...@@ -88,7 +88,7 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -88,7 +88,7 @@ class SyncMLSynchronousEngine(EngineMixin):
# Delete message will contain final tag # Delete message will contain final tag
subscription.getDeletedSyncMLData(syncml_response=syncml_response) subscription.getDeletedSyncMLData(syncml_response=syncml_response)
syncml_logger.info("-> Client sendind modification, finished %s" % (finished,)) syncml_logger.info("-> Client sendind modification, finished %s", finished)
if finished: if finished:
# Will then start processing sync commands from server # Will then start processing sync commands from server
subscription.processSyncRequest() subscription.processSyncRequest()
...@@ -101,8 +101,8 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -101,8 +101,8 @@ class SyncMLSynchronousEngine(EngineMixin):
syncml_request=syncml_request, syncml_request=syncml_request,
syncml_response=syncml_response, syncml_response=syncml_response,
simulate=False) simulate=False)
syncml_logger.info("-> Client sending %s notification of object synchronized" syncml_logger.info("-> Client sending %s notification of object synchronized",
% (syncml_response.sync_confirmation_counter)) syncml_response.sync_confirmation_counter)
if syncml_request.isFinal: if syncml_request.isFinal:
# Notify that all modifications were applied # Notify that all modifications were applied
syncml_response.addFinal() syncml_response.addFinal()
...@@ -137,10 +137,10 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -137,10 +137,10 @@ class SyncMLSynchronousEngine(EngineMixin):
syncml_response = subscriber.getLastSentMessage("") # XXX syncml_response = subscriber.getLastSentMessage("") # XXX
else: else:
syncml_logger.info("xxx Server processing data from client xxx") syncml_logger.info("xxx Server processing data from client xxx")
syncml_logger.info("\tstatus %s, sync %s, final %s" syncml_logger.info("\tstatus %s, sync %s, final %s",
% (len(syncml_request.status_list), len(syncml_request.status_list),
len(syncml_request.sync_command_list), len(syncml_request.sync_command_list),
syncml_request.isFinal)) syncml_request.isFinal)
# we log the user authenticated to do the synchronization with him # we log the user authenticated to do the synchronization with him
if subscriber.getAuthenticationState() == 'logged_in': if subscriber.getAuthenticationState() == 'logged_in':
subscriber._loginUser() subscriber._loginUser()
...@@ -187,8 +187,8 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -187,8 +187,8 @@ class SyncMLSynchronousEngine(EngineMixin):
syncml_response=syncml_response, syncml_response=syncml_response,
simulate=True) simulate=True)
syncml_logger.info("-> Server sending %s notification of sync" syncml_logger.info("-> Server sending %s notification of sync",
% (syncml_response.sync_confirmation_counter)) syncml_response.sync_confirmation_counter)
if syncml_request.isFinal: if syncml_request.isFinal:
# Server will now send its modifications # Server will now send its modifications
subscriber.sendModifications() subscriber.sendModifications()
...@@ -211,7 +211,7 @@ class SyncMLSynchronousEngine(EngineMixin): ...@@ -211,7 +211,7 @@ class SyncMLSynchronousEngine(EngineMixin):
# Delete message will contain final tag # Delete message will contain final tag
subscriber.getDeletedSyncMLData(syncml_response=syncml_response) subscriber.getDeletedSyncMLData(syncml_response=syncml_response)
syncml_logger.info("-> Server sendind data, finished %s" % (finished,)) syncml_logger.info("-> Server sendind data, finished %s", finished)
if finished: if finished:
subscriber.waitNotifications() subscriber.waitNotifications()
# Do not go into finished here as we must wait for # Do not go into finished here as we must wait for
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLEngineSynchronous</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Engine.SynchronousEngine</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLEngineSynchronous</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -29,9 +29,9 @@ from lxml.builder import ElementMaker ...@@ -29,9 +29,9 @@ from lxml.builder import ElementMaker
from lxml.etree import Element from lxml.etree import Element
from lxml import etree from lxml import etree
from Products.ERP5SyncML.XMLSyncUtils import resolveSyncmlStatusCode, \ from erp5.component.module.XMLSyncUtils import resolveSyncmlStatusCode, \
encode, resolveSyncmlAlertCode encode, resolveSyncmlAlertCode
from Products.ERP5SyncML.SyncMLConstant import SYNCML_NAMESPACE, NSMAP from erp5.component.module.SyncMLConstant import SYNCML_NAMESPACE, NSMAP
parser = etree.XMLParser(remove_blank_text=True) parser = etree.XMLParser(remove_blank_text=True)
E = ElementMaker(namespace=SYNCML_NAMESPACE, nsmap=NSMAP) E = ElementMaker(namespace=SYNCML_NAMESPACE, nsmap=NSMAP)
...@@ -224,6 +224,7 @@ class SyncMLResponse(object): ...@@ -224,6 +224,7 @@ class SyncMLResponse(object):
receiving a challenge message receiving a challenge message
""" """
raise NotImplementedError("To review") raise NotImplementedError("To review")
"""
# create element 'SyncML' with a default namespace # create element 'SyncML' with a default namespace
xml = E.SyncML() xml = E.SyncML()
# syncml header # syncml header
...@@ -257,6 +258,7 @@ class SyncMLResponse(object): ...@@ -257,6 +258,7 @@ class SyncMLResponse(object):
xml_string = etree.tostring(xml, encoding='utf-8', xml_declaration=True, xml_string = etree.tostring(xml, encoding='utf-8', xml_declaration=True,
pretty_print=True) pretty_print=True)
self.data_append(xml_string) self.data_append(xml_string)
"""
def addPutMessage(self,subscription, markup='Put', def addPutMessage(self,subscription, markup='Put',
cmd_ref=None, message_id=None): cmd_ref=None, message_id=None):
...@@ -277,6 +279,7 @@ class SyncMLResponse(object): ...@@ -277,6 +279,7 @@ class SyncMLResponse(object):
Both must be able to handle and process these informations Both must be able to handle and process these informations
""" """
return return
"""
# XXX-Aurel : must be reviewed according to specification # XXX-Aurel : must be reviewed according to specification
# This part can be skipped for now # This part can be skipped for now
conduit = subscription.getConduit() conduit = subscription.getConduit()
...@@ -330,6 +333,7 @@ class SyncMLResponse(object): ...@@ -330,6 +333,7 @@ class SyncMLResponse(object):
E.SyncType('6') E.SyncType('6')
)) ))
self.data_append(xml) self.data_append(xml)
"""
def addSyncCommand(self, sync_command, gid, data, media_type, more_data): def addSyncCommand(self, sync_command, gid, data, media_type, more_data):
...@@ -583,8 +587,8 @@ class SyncMLRequest(object): ...@@ -583,8 +587,8 @@ class SyncMLRequest(object):
data = sync_command.xpath('string(.//syncml:Item/syncml:Data)', data = sync_command.xpath('string(.//syncml:Item/syncml:Data)',
namespaces=self.data.nsmap) namespaces=self.data.nsmap)
if isinstance(data, etree.CDATA): if isinstance(data, etree.CDATA):
parser = etree.XMLParser(strip_cdata=False) parser_ = etree.XMLParser(strip_cdata=False)
cdata = etree.XML(data, parser) cdata = etree.XML(data, parser_)
data = cdata.text data = cdata.text
# XXX this is unicode and can be a problem for activity # XXX this is unicode and can be a problem for activity
sync_command_kw["raw_data"] = data sync_command_kw["raw_data"] = data
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLMessage</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.SyncMLMessage</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLMessage</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLTransportERP5</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Transport.ERP5</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLTransportERP5</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -25,10 +25,7 @@ ...@@ -25,10 +25,7 @@
# #
############################################################################## ##############################################################################
from erp5.component.module.SyncMLTransportHTTP import ConnectionError
from HTTP import ConnectionError
class FileTransport: class FileTransport:
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLTransportFile</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Transport.File</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLTransportFile</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -63,7 +63,7 @@ class HTTPTransport: ...@@ -63,7 +63,7 @@ class HTTPTransport:
def send(self, to_url, data, sync_id, content_type): def send(self, to_url, data, sync_id, content_type):
syncml_logger.debug("HTTP.send : %s" %(to_url,)) syncml_logger.debug("HTTP.send : %s", to_url)
data = { data = {
'text' : data, 'text' : data,
'sync_id': sync_id 'sync_id': sync_id
...@@ -72,5 +72,5 @@ class HTTPTransport: ...@@ -72,5 +72,5 @@ class HTTPTransport:
headers=self.getHeaders(content_type, data), headers=self.getHeaders(content_type, data),
timeout=60, timeout=60,
proxies=self.getProxyMapping()) proxies=self.getProxyMapping())
syncml_logger.debug("Status code : %s - %s" %(r.status_code, r.headers)) syncml_logger.debug("Status code : %s - %s", r.status_code, r.headers)
r.raise_for_status() r.raise_for_status()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLTransportHTTP</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Transport.HTTP</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLTransportHTTP</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -25,11 +25,9 @@ ...@@ -25,11 +25,9 @@
# #
############################################################################## ##############################################################################
from erp5.component.module.SyncMLTransportHTTP import ConnectionError
from HTTP import ConnectionError
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
class MailTransport: class MailTransport:
def send(self, from_url, to_url, xml, sync_id, content_type): def send(self, from_url, to_url, xml, sync_id, content_type):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLTransportMail</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Transport.Mail</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLTransportMail</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -68,20 +68,20 @@ class PdataHelper(persistent.Persistent): ...@@ -68,20 +68,20 @@ class PdataHelper(persistent.Persistent):
n = self._max_len n = self._max_len
if isinstance(value, (str, unicode)): if isinstance(value, (str, unicode)):
if isinstance(value, unicode): if isinstance(value, unicode):
value = value.encode('utf-8') value = value.encode('utf-8')
size=len(value) size=len(value)
if size < n: if size < n:
return Pdata(value), size return Pdata(value), size
# Big string: cut it into smaller chunks # Big string: cut it into smaller chunks
value = StringIO(value) value = StringIO(value)
if isinstance(value, FileUpload) and not value: if isinstance(value, FileUpload) and not value:
raise ValueError, 'File not specified' raise ValueError, 'File not specified'
if isinstance(value, Pdata): if isinstance(value, Pdata):
size = self._read_size_from_pdata(value) size = self._read_size_from_pdata(value)
return value, size return value, size
# Clear md5sum to force refreshing # Clear md5sum to force refreshing
self.md5sum = None self.md5sum = None
...@@ -93,66 +93,66 @@ class PdataHelper(persistent.Persistent): ...@@ -93,66 +93,66 @@ class PdataHelper(persistent.Persistent):
size=end=value.tell() size=end=value.tell()
if size <= 2*n: if size <= 2*n:
seek(0) seek(0)
return Pdata(read(size)), size return Pdata(read(size)), size
# Make sure we have an _p_jar, even if we are a new object, by # Make sure we have an _p_jar, even if we are a new object, by
# doing a sub-transaction commit. # doing a sub-transaction commit.
transaction.savepoint(optimistic=True) transaction.savepoint(optimistic=True)
if persistent_object._p_jar is None: if persistent_object._p_jar is None:
# Ugh # Ugh
seek(0) seek(0)
return Pdata(read(size)), size return Pdata(read(size)), size
# Now we're going to build a linked list from back # Now we're going to build a linked list from back
# to front to minimize the number of database updates # to front to minimize the number of database updates
# and to allow us to get things out of memory as soon as # and to allow us to get things out of memory as soon as
# possible. # possible.
next = None next_ = None
while end > 0: while end > 0:
pos = end-n pos = end-n
if pos < n: if pos < n:
pos = 0 # we always want at least n bytes pos = 0 # we always want at least n bytes
seek(pos) seek(pos)
# Create the object and assign it a next pointer # Create the object and assign it a next pointer
# in the same transaction, so that there is only # in the same transaction, so that there is only
# a single database update for it. # a single database update for it.
data = Pdata(read(end-pos)) data = Pdata(read(end-pos))
persistent_object._p_jar.add(data) persistent_object._p_jar.add(data)
data.next = next data.next = next_
# Save the object so that we can release its memory. # Save the object so that we can release its memory.
transaction.savepoint(optimistic=True) transaction.savepoint(optimistic=True)
data._p_deactivate() data._p_deactivate()
# The object should be assigned an oid and be a ghost. # The object should be assigned an oid and be a ghost.
assert data._p_oid is not None assert data._p_oid is not None
assert data._p_state == -1 assert data._p_state == -1
next = data next_ = data
end = pos end = pos
return next, size return next_, size
def _digest_md5_hash_from_pdata(self, pdata): def _digest_md5_hash_from_pdata(self, pdata):
"""Compute hash part by part """Compute hash part by part
""" """
md5_hash = md5() md5_hash = md5()
next = pdata next_ = pdata
while next is not None: while next_ is not None:
md5_hash.update(next.data) md5_hash.update(next_.data)
next = next.next next_ = next_.next
return md5_hash.hexdigest() return md5_hash.hexdigest()
def _read_size_from_pdata(self, pdata): def _read_size_from_pdata(self, pdata):
"""Compute size part by part """Compute size part by part
""" """
size = 0 size = 0
next = pdata next_ = pdata
while next is not None: while next_ is not None:
size += len(next.data) size += len(next_.data)
next = next.next next_ = next_.next
return size return size
def __len__(self): def __len__(self):
...@@ -186,9 +186,9 @@ class PdataHelper(persistent.Persistent): ...@@ -186,9 +186,9 @@ class PdataHelper(persistent.Persistent):
of a Pdata chains of a Pdata chains
""" """
pdata = self._data pdata = self._data
next = pdata.next next_ = pdata.next
while next is not None: while next_ is not None:
pdata = next pdata = next_
next = pdata.next next_ = pdata.next
return pdata return pdata
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SyncMLUtils</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Utils</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.SyncMLUtils</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from erp5.component.module.ERP5Conduit import ERP5Conduit
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
import difflib import difflib
...@@ -48,7 +48,7 @@ class VCardConduit(ERP5Conduit): ...@@ -48,7 +48,7 @@ class VCardConduit(ERP5Conduit):
security.declareProtected(Permissions.ModifyPortalContent, 'addNode') security.declareProtected(Permissions.ModifyPortalContent, 'addNode')
def addNode(self, xml=None, object=None, previous_xml=None, def addNode(self, xml=None, object=None, previous_xml=None, # pylint: disable=redefined-builtin
object_id=None, sub_object=None, force=0, simulate=0, **kw): object_id=None, sub_object=None, force=0, simulate=0, **kw):
""" """
add a new person corresponding to the vcard add a new person corresponding to the vcard
...@@ -61,8 +61,7 @@ class VCardConduit(ERP5Conduit): ...@@ -61,8 +61,7 @@ class VCardConduit(ERP5Conduit):
portal_type = 'Person' #the VCard can just use Person portal_type = 'Person' #the VCard can just use Person
if sub_object is None: if sub_object is None:
new_object, reset_local_roles, reset_workflow =\ new_object, _, _ = ERP5Conduit.constructContent(self, object, object_id, portal_type)
ERP5Conduit.constructContent(self, object, object_id, portal_type)
else: #if the object exist, it juste must be update else: #if the object exist, it juste must be update
new_object = sub_object new_object = sub_object
#LOG('addNode', 0, 'new_object:%s, sub_object:%s' % (new_object, sub_object)) #LOG('addNode', 0, 'new_object:%s, sub_object:%s' % (new_object, sub_object))
...@@ -75,7 +74,7 @@ class VCardConduit(ERP5Conduit): ...@@ -75,7 +74,7 @@ class VCardConduit(ERP5Conduit):
return {'conflict_list':[], 'object': new_object} return {'conflict_list':[], 'object': new_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, # pylint: disable=redefined-builtin
simulate=0, **kw): simulate=0, **kw):
""" """
A node is deleted A node is deleted
...@@ -88,7 +87,7 @@ class VCardConduit(ERP5Conduit): ...@@ -88,7 +87,7 @@ class VCardConduit(ERP5Conduit):
return [] return []
security.declareProtected(Permissions.ModifyPortalContent, 'updateNode') security.declareProtected(Permissions.ModifyPortalContent, 'updateNode')
def updateNode(self, xml=None, object=None, previous_xml=None, force=0, def updateNode(self, xml=None, object=None, previous_xml=None, force=0, # pylint: disable=redefined-builtin
simulate=0, **kw): simulate=0, **kw):
""" """
A node is updated A node is updated
...@@ -165,12 +164,12 @@ class VCardConduit(ERP5Conduit): ...@@ -165,12 +164,12 @@ class VCardConduit(ERP5Conduit):
vcard_list = vcard.split('\n') vcard_list = vcard.split('\n')
for vcard_line in vcard_list: for vcard_line in vcard_list:
if ':' in vcard_line: if ':' in vcard_line:
property, property_value = vcard_line.split(':') property_, property_value = vcard_line.split(':')
property_value_list = property_value.split(';') property_value_list = property_value.split(';')
property_parameters_list = [] property_parameters_list = []
property_name = '' property_name = ''
if ';' in property: if ';' in property_:
property_list = property.split(';') property_list = property_.split(';')
property_name = property_list[0] #the property name is the 1st element property_name = property_list[0] #the property name is the 1st element
if len(property_list) > 1 and property_list[1] != '': if len(property_list) > 1 and property_list[1] != '':
property_parameters_list = property_list[1:len(property_list)] property_parameters_list = property_list[1:len(property_list)]
...@@ -192,7 +191,7 @@ class VCardConduit(ERP5Conduit): ...@@ -192,7 +191,7 @@ class VCardConduit(ERP5Conduit):
property_value_list) property_value_list)
else: else:
property_name=property property_name=property_
if isinstance(property_name, unicode): if isinstance(property_name, unicode):
property_name = property_name.encode('utf-8') property_name = property_name.encode('utf-8')
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>VCardConduit</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.Conduit.VCardConduit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.VCardConduit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -37,7 +37,7 @@ from zLOG import LOG, INFO ...@@ -37,7 +37,7 @@ from zLOG import LOG, INFO
from ERP5Diff import ERP5Diff from ERP5Diff import ERP5Diff
from DateTime import DateTime from DateTime import DateTime
from SyncMLConstant import SYNCML_NAMESPACE, NSMAP, MAX_LEN from erp5.component.module.SyncMLConstant import SYNCML_NAMESPACE, NSMAP, MAX_LEN
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
E = ElementMaker(namespace=SYNCML_NAMESPACE, nsmap=NSMAP) E = ElementMaker(namespace=SYNCML_NAMESPACE, nsmap=NSMAP)
...@@ -51,7 +51,7 @@ def buildAnchorFromDate(date): ...@@ -51,7 +51,7 @@ def buildAnchorFromDate(date):
return date return date
def encode(format, string_to_encode): def encode(format, string_to_encode): # pylint: disable=redefined-builtin
""" """
return the string_to_encode encoded with format format return the string_to_encode encoded with format format
""" """
...@@ -65,7 +65,7 @@ def encode(format, string_to_encode): ...@@ -65,7 +65,7 @@ def encode(format, string_to_encode):
raise ValueError, "Sorry, the server ask for the format %s but \ raise ValueError, "Sorry, the server ask for the format %s but \
it's unknow or not implemented" % format it's unknow or not implemented" % format
def decode(format, string_to_decode): def decode(format, string_to_decode): # pylint: disable=redefined-builtin
""" """
return the string_to_decode decoded with format format return the string_to_decode decoded with format format
""" """
...@@ -80,7 +80,7 @@ def decode(format, string_to_decode): ...@@ -80,7 +80,7 @@ def decode(format, string_to_decode):
raise ValueError, "Sorry, the format %s is unknow or \ raise ValueError, "Sorry, the format %s is unknow or \
not implemented" % format not implemented" % format
def isDecodeEncodeTheSame(string_encoded, string_decoded, format): def isDecodeEncodeTheSame(string_encoded, string_decoded, format): # pylint: disable=redefined-builtin
""" """
return True if the string_encoded is equal to string_decoded encoded return True if the string_encoded is equal to string_decoded encoded
in format in format
...@@ -121,7 +121,7 @@ def getConduitByName(conduit_name): ...@@ -121,7 +121,7 @@ def getConduitByName(conduit_name):
Get Conduit Object by given name. Get Conduit Object by given name.
The Conduit can be located in Any Products according to naming Convention The Conduit can be located in Any Products according to naming Convention
Products.<Product Name>.Conduit.<Conduit Module> ,if conduit_name equal module's name. Products.<Product Name>.Conduit.<Conduit Module> ,if conduit_name equal module's name.
By default Conduit must be defined in Products.ERP5SyncML.Conduit.<Conduit Module> By default Conduit must be defined as ZODB Components (erp5.component.module.<Conduit Module>)
Conduit can also be defined as Extension to have it editable through the web, in this Conduit can also be defined as Extension to have it editable through the web, in this
case its definition must be Extensions.<Conduit Module> case its definition must be Extensions.<Conduit Module>
""" """
...@@ -136,9 +136,7 @@ def getConduitByName(conduit_name): ...@@ -136,9 +136,7 @@ def getConduitByName(conduit_name):
conduit_module = __import__("erp5.component."+conduit_name, globals(), locals(), ['']) conduit_module = __import__("erp5.component."+conduit_name, globals(), locals(), [''])
conduit_name = conduit_name.split('.')[-1] conduit_name = conduit_name.split('.')[-1]
else: else:
from Products.ERP5SyncML import Conduit conduit_module = __import__('erp5.component.module.'+conduit_name, globals(), locals(), [''])
conduit_module = __import__('.'.join([Conduit.__name__, conduit_name]),
globals(), locals(), [''])
conduit_instance = getattr(conduit_module, conduit_name)() conduit_instance = getattr(conduit_module, conduit_name)()
return conduit_instance return conduit_instance
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>XMLSyncUtils</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.XMLSyncUtils</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.XMLSyncUtils</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5SyncML.XMLSyncUtils import XMLSyncUtilsMixin from erp5.component.module.XMLSyncUtils import XMLSyncUtilsMixin
from xml.dom.ext.reader.Sax2 import FromXml from xml.dom.ext.reader.Sax2 import FromXml
class XupdateUtils(XMLSyncUtilsMixin): class XupdateUtils(XMLSyncUtilsMixin):
...@@ -35,7 +35,7 @@ class XupdateUtils(XMLSyncUtilsMixin): ...@@ -35,7 +35,7 @@ class XupdateUtils(XMLSyncUtilsMixin):
this is the place where we should parse xupdate data. this is the place where we should parse xupdate data.
""" """
def applyXupdate(self, object=None, xupdate=None, conduit=None, force=0, **kw): def applyXupdate(self, object=None, xupdate=None, conduit=None, force=0, **kw): # pylint: disable=redefined-builtin
""" """
Parse the xupdate and then it will call the conduit Parse the xupdate and then it will call the conduit
""" """
...@@ -44,7 +44,6 @@ class XupdateUtils(XMLSyncUtilsMixin): ...@@ -44,7 +44,6 @@ class XupdateUtils(XMLSyncUtilsMixin):
xupdate = FromXml(xupdate) xupdate = FromXml(xupdate)
for subnode in xupdate: for subnode in xupdate:
selection_name = ''
if subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD: if subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD:
conflict_list.extend(conduit.addNode(xml=subnode, object=object, \ conflict_list.extend(conduit.addNode(xml=subnode, object=object, \
force=force, **kw)) force=force, **kw))
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>XupdateUtils</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.XupdateUtils</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.XupdateUtils</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -99,5 +99,4 @@ class TestERP5SyncMLMixin(ERP5TypeTestCase): ...@@ -99,5 +99,4 @@ class TestERP5SyncMLMixin(ERP5TypeTestCase):
portal_type="SyncML Subscription") portal_type="SyncML Subscription")
for subscription in subscription_list: for subscription in subscription_list:
if self.portal.portal_workflow.isTransitionPossible(subscription, 'validate'): if self.portal.portal_workflow.isTransitionPossible(subscription, 'validate'):
subscription.validate() subscription.validate()
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Module Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testERP5SyncMLMixin</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.tests.testERP5SyncMLMixin</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>module.erp5.testERP5SyncMLMixin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Module Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testERP5DocumentSyncML</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5SyncML.tests.testERP5DocumentSyncML</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testERP5DocumentSyncML</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -35,14 +35,13 @@ from unittest import expectedFailure ...@@ -35,14 +35,13 @@ from unittest import expectedFailure
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from ERP5Diff import ERP5Diff from ERP5Diff import ERP5Diff
from Products.ERP5Type.tests.runUnitTest import tests_home from erp5.component.module.ERP5Conduit import ERP5Conduit
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from erp5.component.module.XMLSyncUtils import encode, decode,\
from Products.ERP5SyncML.XMLSyncUtils import encode, decode,\
isDecodeEncodeTheSame isDecodeEncodeTheSame
from Products.ERP5SyncML.XMLSyncUtils import getConduitByName from erp5.component.module.XMLSyncUtils import getConduitByName
from Products.ERP5SyncML.SyncMLConstant import MAX_LEN from erp5.component.module.SyncMLConstant import MAX_LEN
from Products.ERP5SyncML.Document import SyncMLSubscription from erp5.component.document import SyncMLSubscription
from Products.ERP5SyncML.tests.testERP5SyncMLMixin import TestERP5SyncMLMixin \ from erp5.component.module.testERP5SyncMLMixin import TestERP5SyncMLMixin \
as TestMixin as TestMixin
class TestERP5SyncMLMixin(TestMixin): class TestERP5SyncMLMixin(TestMixin):
...@@ -83,12 +82,6 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -83,12 +82,6 @@ class TestERP5SyncMLMixin(TestMixin):
nb_synchronization = 3 nb_synchronization = 3
nb_message_first_synchronization = 6 nb_message_first_synchronization = 6
nb_message_first_sync_max_lines = 16 nb_message_first_sync_max_lines = 16
_subscription_url1 = tests_home + '/sync_client1'
_subscription_url2 = tests_home + '/sync_client2'
_publication_url = tests_home + '/sync_server'
subscription_url1 = 'file:/' + _subscription_url1
subscription_url2 = 'file:/' + _subscription_url2
publication_url = 'file:/' + _publication_url
activity_enabled = False activity_enabled = False
...@@ -104,6 +97,14 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -104,6 +97,14 @@ class TestERP5SyncMLMixin(TestMixin):
# allow anything inside Person (we'll cleanup on teardown) # allow anything inside Person (we'll cleanup on teardown)
self.getTypesTool().getTypeInfo('Person').filter_content_types = 0 self.getTypesTool().getTypeInfo('Person').filter_content_types = 0
from Products.ERP5Type.tests.runUnitTest import tests_home
self._subscription_url1 = tests_home + '/sync_client1'
self._subscription_url2 = tests_home + '/sync_client2'
self._publication_url = tests_home + '/sync_server'
self.subscription_url1 = 'file:/' + self._subscription_url1
self.subscription_url2 = 'file:/' + self._subscription_url2
self.publication_url = 'file:/' + self._publication_url
def beforeTearDown(self): def beforeTearDown(self):
"""Clean up.""" """Clean up."""
self.getTypesTool().getTypeInfo('Person').filter_content_types = 1 self.getTypesTool().getTypeInfo('Person').filter_content_types = 1
...@@ -132,7 +133,7 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -132,7 +133,7 @@ class TestERP5SyncMLMixin(TestMixin):
def getPersonClient2(self): def getPersonClient2(self):
return getattr(self.getPortalObject(), 'person_client2', None) return getattr(self.getPortalObject(), 'person_client2', None)
def login(self): def login(self, *args, **kw):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser('fab', 'myPassword', ['Manager'], []) uf._doAddUser('fab', 'myPassword', ['Manager'], [])
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], []) uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], [])
...@@ -180,9 +181,9 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -180,9 +181,9 @@ class TestERP5SyncMLMixin(TestMixin):
self.initPersonModule() self.initPersonModule()
person_client = self.getPersonClient1() person_client = self.getPersonClient1()
number_of_object = 60 number_of_object = 60
for id in range(1, number_of_object+1): for id_ in range(1, number_of_object+1):
person_client.newContent(portal_type='Person', person_client.newContent(portal_type='Person',
id=id, id=id_,
first_name=self.first_name1, first_name=self.first_name1,
last_name=self.last_name1, last_name=self.last_name1,
description=self.description1) description=self.description1)
...@@ -193,17 +194,17 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -193,17 +194,17 @@ class TestERP5SyncMLMixin(TestMixin):
def clearFiles(self): def clearFiles(self):
# reset files, because we do sync by files # reset files, because we do sync by files
file = open(self._subscription_url1, 'w') file_ = open(self._subscription_url1, 'w')
file.write('') file_.write('')
file.close() file_.close()
file = open(self._subscription_url2, 'w') file_ = open(self._subscription_url2, 'w')
file.write('') file_.write('')
file.close() file_.close()
file = open(self._publication_url, 'w') file_ = open(self._publication_url, 'w')
file.write('') file_.write('')
file.close() file_.close()
def synchronize(self, id): def synchronize(self, id): # pylint: disable=redefined-builtin
""" """
This just define how we synchronize, we have This just define how we synchronize, we have
to define it here because it is specific to the unit testing to define it here because it is specific to the unit testing
...@@ -233,7 +234,7 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -233,7 +234,7 @@ class TestERP5SyncMLMixin(TestMixin):
self.tic() self.tic()
return nb_message return nb_message
def synchronizeWithBrokenMessage(self, id): def synchronizeWithBrokenMessage(self, id): # pylint: disable=redefined-builtin
""" """
This just define how we synchronize, we have This just define how we synchronize, we have
to define it here because it is specific to the unit testing to define it here because it is specific to the unit testing
...@@ -254,7 +255,7 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -254,7 +255,7 @@ class TestERP5SyncMLMixin(TestMixin):
# only first call will return an answer # only first call will return an answer
result = portal_sync.processServerSynchronization(publication.getPath()) result = portal_sync.processServerSynchronization(publication.getPath())
self.tic() self.tic()
for x in xrange(2): for _ in xrange(2):
portal_sync.processServerSynchronization(publication.getPath()) portal_sync.processServerSynchronization(publication.getPath())
self.tic() self.tic()
nb_message += 1 nb_message += 1
...@@ -262,7 +263,7 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -262,7 +263,7 @@ class TestERP5SyncMLMixin(TestMixin):
break break
result = portal_sync.processClientSynchronization(subscription.getPath()) result = portal_sync.processClientSynchronization(subscription.getPath())
self.tic() self.tic()
for x in xrange(2): for _ in xrange(2):
portal_sync.processClientSynchronization(subscription.getPath()) portal_sync.processClientSynchronization(subscription.getPath())
self.tic() self.tic()
nb_message += 1 nb_message += 1
...@@ -365,7 +366,7 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -365,7 +366,7 @@ class TestERP5SyncMLMixin(TestMixin):
self.assertEqual(person_client.getFirstName(), first_name) self.assertEqual(person_client.getFirstName(), first_name)
self.assertEqual(person_client.getLastName(), last_name) self.assertEqual(person_client.getLastName(), last_name)
def checkFirstSynchronization(self, id=None, nb_person=0): def checkFirstSynchronization(self, id=None, nb_person=0): # pylint: disable=redefined-builtin
portal_sync = self.getSynchronizationTool() portal_sync = self.getSynchronizationTool()
subscription1 = portal_sync[self.sub_id1] subscription1 = portal_sync[self.sub_id1]
...@@ -451,7 +452,7 @@ class TestERP5SyncMLMixin(TestMixin): ...@@ -451,7 +452,7 @@ class TestERP5SyncMLMixin(TestMixin):
def deletePublicationAndSubscriptionList(self): def deletePublicationAndSubscriptionList(self):
portal_sync = self.getSynchronizationTool() portal_sync = self.getSynchronizationTool()
id_list = [id for id in portal_sync.objectIds()] id_list = [id_ for id_ in portal_sync.objectIds()]
portal_sync.manage_delObjects(id_list) portal_sync.manage_delObjects(id_list)
class TestERP5SyncML(TestERP5SyncMLMixin): class TestERP5SyncML(TestERP5SyncMLMixin):
...@@ -1153,13 +1154,13 @@ return [context[%r]] ...@@ -1153,13 +1154,13 @@ return [context[%r]]
for conflict in conflict_list : for conflict in conflict_list :
subscriber = conflict.getSubscriber() subscriber = conflict.getSubscriber()
property = conflict.getPropertyId() property_id = conflict.getPropertyId()
resolve = 0 resolve = 0
if property == 'language': if property_id == 'language':
if subscriber.getUrlString() == self.subscription_url1: if subscriber.getUrlString() == self.subscription_url1:
resolve = 1 resolve = 1
conflict.applySubscriberValue() conflict.applySubscriberValue()
if property == 'format': if property_id == 'format':
if subscriber.getUrlString() == self.subscription_url2: if subscriber.getUrlString() == self.subscription_url2:
resolve = 1 resolve = 1
conflict.applySubscriberValue() conflict.applySubscriberValue()
...@@ -1261,7 +1262,7 @@ return [context[%r]] ...@@ -1261,7 +1262,7 @@ return [context[%r]]
If we want to make this test more intersting, it is If we want to make this test more intersting, it is
better to split messages better to split messages
""" """
from Products.ERP5SyncML import SyncMLConstant from erp5.component.module import SyncMLConstant
previous_max_lines = SyncMLConstant.MAX_LEN previous_max_lines = SyncMLConstant.MAX_LEN
try: try:
SyncMLConstant.MAX_LEN = 1 << 8 SyncMLConstant.MAX_LEN = 1 << 8
...@@ -1875,15 +1876,15 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA==" ...@@ -1875,15 +1876,15 @@ wuIFtde33Dp3NkZl9fc2Rmw6fDp8OnX2RmX19fJibDqV1dXcKwwrDCsMKwwrDCsA=="
self.assertEqual(nb_person, len(person_client1.objectValues())) self.assertEqual(nb_person, len(person_client1.objectValues()))
self.assertEqual(nb_person, len(person_client2.objectValues())) self.assertEqual(nb_person, len(person_client2.objectValues()))
for id in range(1, 60): for id_ in range(1, 60):
person_s = person_server._getOb(str(id)) person_s = person_server._getOb(str(id_))
person_c1 = person_client1._getOb(str(id)) person_c1 = person_client1._getOb(str(id_))
person_c2 = person_client2._getOb(str(id)) person_c2 = person_client2._getOb(str(id_))
self.assertXMLViewIsEqual(self.sub_id1, person_s, person_c1) self.assertXMLViewIsEqual(self.sub_id1, person_s, person_c1)
self.assertXMLViewIsEqual(self.sub_id1, person_s, person_c2) self.assertXMLViewIsEqual(self.sub_id1, person_s, person_c2)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5SyncML)) suite.addTest(unittest.makeSuite(TestERP5SyncML))
return suite return suite
\ No newline at end of file
This diff is collapsed.
interface.erp5.IConduit
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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