Commit 7c6a9ebd authored by Nicolas Delaby's avatar Nicolas Delaby

SyncML Class refactoring: call activate on Sub an Pub objects, for scalability improvements

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15774 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 16b8f49f
......@@ -69,7 +69,7 @@ class PublicationSynchronization(XMLSyncUtils):
last_anchor = self.getAlertLastAnchor(xml_client)
next_anchor = self.getAlertNextAnchor(xml_client)
alert = self.checkAlert(xml_client)
alert_code = self.getAlertCode(xml_client)
alert_code = self.getAlertCodeFromXML(xml_client)
cred = self.checkCred(xml_client)
#the source and the target of the subscriber are reversed compared
......@@ -222,7 +222,7 @@ class PublicationSynchronization(XMLSyncUtils):
if first_node.nodeName != "SyncML":
LOG('PubSync', INFO, 'This is not a SyncML Message')
raise ValueError, "Sorry, This is not a SyncML Message"
alert_code = self.getAlertCode(xml_client)
alert_code = self.getAlertCodeFromXML(xml_client)
# Get informations from the header
client_header = first_node.childNodes[1]
if client_header.nodeName != "SyncHdr":
......
......@@ -36,6 +36,7 @@ from Products.ERP5Type.Core.Folder import Folder
from Products.ERP5Type.Base import Base
from Products.ERP5Type import Permissions
from Products.ERP5Type import PropertySheet
from XMLSyncUtils import XMLSyncUtils
from DateTime import DateTime
from zLOG import LOG, DEBUG, INFO
......@@ -585,7 +586,7 @@ def addSubscription( self, id, title='', REQUEST=None ):
#class Subscription(SyncCode, Implicit):
#class Subscription(Folder, SyncCode, Implicit, Folder, Impli):
class Subscription(Folder, SyncCode):
class Subscription(Folder, XMLSyncUtils):
"""
Subscription hold the definition of a master ODB
from/to which a selection of objects will be synchronised
......
......@@ -187,9 +187,6 @@ class SynchronizationTool( SubscriptionSynchronization,
"""
create a new publication
"""
#if not('publications' in self.objectIds()):
# publications = Folder('publications')
# self._setObject(publications.id, publications)
folder = self.getObjectContainer()
new_id = self.getPublicationIdFromTitle(title)
pub = Publication(new_id, title, publication_url,
......@@ -201,9 +198,6 @@ class SynchronizationTool( SubscriptionSynchronization,
activity_enabled, synchronize_with_erp5_sites,
sync_content_type)
folder._setObject( new_id, pub )
#if len(self.list_publications) == 0:
# self.list_publications = PersistentMapping()
#self.list_publications[id] = pub
if RESPONSE is not None:
RESPONSE.redirect('managePublications')
......
......@@ -630,7 +630,7 @@ class XMLSyncUtilsMixin(SyncCode):
rid = map_item.xpath('string(.//Source/LocURI)').encode('utf-8')
signature.setRid(rid)
def getAlertCode(self, xml_stream):
def getAlertCodeFromXML(self, xml_stream):
"""
Return the value of the alert code inside the full syncml message
"""
......@@ -840,11 +840,11 @@ class XMLSyncUtilsMixin(SyncCode):
# If not we have to cut
LOG('getSyncMLData', DEBUG, 'object_path: %s' % '/'.join(object_path))
LOG('getSyncMLData', DEBUG, 'xml_mapping: %s' % str(domain.getXMLMapping()))
LOG('getSyncMLData', DEBUG, 'code: %s' % str(self.getAlertCode(remote_xml)))
LOG('getSyncMLData', DEBUG, 'code: %s' % str(self.getAlertCodeFromXML(remote_xml)))
LOG('getSyncMLData', DEBUG, 'gid_list: %s' % str(local_gid_list))
LOG('getSyncMLData', DEBUG, 'subscriber.getGidList: %s' % subscriber.getGidList())
LOG('getSyncMLData', DEBUG, 'hasSignature: %s' % str(subscriber.hasSignature(object_gid)))
LOG('getSyncMLData', DEBUG, 'alert_code == slowsync: %s' % str(self.getAlertCode(remote_xml) == self.SLOW_SYNC))
LOG('getSyncMLData', DEBUG, 'alert_code == slowsync: %s' % str(self.getAlertCodeFromXML(remote_xml) == self.SLOW_SYNC))
signature = subscriber.getSignatureFromGid(object_gid)
## Here we first check if the object was modified or not by looking at dates
......@@ -857,7 +857,7 @@ class XMLSyncUtilsMixin(SyncCode):
pass
elif signature is None or (signature.getXML() is None and \
signature.getStatus() != self.PARTIAL) or \
self.getAlertCode(remote_xml) == self.SLOW_SYNC:
self.getAlertCodeFromXML(remote_xml) == self.SLOW_SYNC:
LOG('getSyncMLData', DEBUG, 'Current object.getPath: %s' % object.getPath())
xml_object = domain.getXMLFromObject(object)
xml_string = xml_object
......@@ -1367,7 +1367,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
subscriber=subscriber,
remote_xml=remote_xml)
alert_code = self.getAlertCode(remote_xml)
alert_code = self.getAlertCodeFromXML(remote_xml)
# Import the conduit and get it
conduit = self.getConduitByName(subscriber.getConduit())
# Then apply the list of actions
......@@ -1426,7 +1426,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
string_io = StringIO()
PrettyPrint(remote_xml,stream=string_io)
remote_xml = string_io.getvalue()
self.activate(activity='SQLQueue').SyncModifActivity(
domain.activate(activity='SQLQueue').SyncModifActivity(
domain_relative_url = domain.getRelativeUrl(),
remote_xml = remote_xml,
subscriber_relative_url = subscriber.getRelativeUrl(),
......@@ -1469,7 +1469,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
kw['cmd_id'] = cmd_id
finished = result['finished']
if not finished:
self.activate(activity='SQLQueue').SyncModifActivity(**kw)
domain.activate(activity='SQLQueue').SyncModifActivity(**kw)
else:
xml_confirmation = result['xml_confirmation']
cmd_id = result['cmd_id']
......
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