[Erp5-report] r15774 - /erp5/trunk/products/ERP5SyncML/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Aug 21 18:18:54 CEST 2007


Author: nicolas
Date: Tue Aug 21 18:18:53 2007
New Revision: 15774

URL: http://svn.erp5.org?rev=15774&view=rev
Log:
SyncML Class refactoring: call activate on Sub an Pub objects, for scalability improvements

Modified:
    erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py
    erp5/trunk/products/ERP5SyncML/Subscription.py
    erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
    erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py

Modified: erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py?rev=15774&r1=15773&r2=15774&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py (original)
+++ erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py Tue Aug 21 18:18:53 2007
@@ -69,7 +69,7 @@
       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 @@
       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":

Modified: erp5/trunk/products/ERP5SyncML/Subscription.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Subscription.py?rev=15774&r1=15773&r2=15774&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Subscription.py (original)
+++ erp5/trunk/products/ERP5SyncML/Subscription.py Tue Aug 21 18:18:53 2007
@@ -36,6 +36,7 @@
 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 @@
 
 #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

Modified: erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SynchronizationTool.py?rev=15774&r1=15773&r2=15774&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SynchronizationTool.py (original)
+++ erp5/trunk/products/ERP5SyncML/SynchronizationTool.py Tue Aug 21 18:18:53 2007
@@ -173,23 +173,20 @@
                     + '?manage_tabs_message=Tool+updated.'
                     )
 
-  security.declareProtected(Permissions.ModifyPortalContent, 
+  security.declareProtected(Permissions.ModifyPortalContent,
       'manage_addPublication')
-  def manage_addPublication(self, title, publication_url, 
-            destination_path, source_uri, query, xml_mapping, 
-            conduit, gpg_key, 
+  def manage_addPublication(self, title, publication_url,
+            destination_path, source_uri, query, xml_mapping,
+            conduit, gpg_key,
             synchronization_id_generator=None, 
-            media_type=None, authentication_format='b64', 
-            authentication_type='syncml:auth-basic', 
+            media_type=None, authentication_format='b64',
+            authentication_type='syncml:auth-basic',
             RESPONSE=None, activity_enabled = False,
-            sync_content_type='application/vnd.syncml+xml', 
+            sync_content_type='application/vnd.syncml+xml',
             synchronize_with_erp5_sites=True):
     """
       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 @@
                       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')
 

Modified: erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py?rev=15774&r1=15773&r2=15774&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py (original)
+++ erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py Tue Aug 21 18:18:53 2007
@@ -57,8 +57,8 @@
 
 class XMLSyncUtilsMixin(SyncCode):
 
-  def SyncMLHeader(self, session_id, msg_id, target, source, target_name=None, 
-      source_name=None, dataCred=None, authentication_format='b64', 
+  def SyncMLHeader(self, session_id, msg_id, target, source, target_name=None,
+      source_name=None, dataCred=None, authentication_format='b64',
       authentication_type='syncml:auth-basic'):
     """
       Since the Header is always almost the same, this is the
@@ -630,7 +630,7 @@
       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 @@
         # 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 @@
           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 @@
                                                       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 @@
         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 @@
     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']




More information about the Erp5-report mailing list