[Erp5-report] r15587 - in /erp5/trunk/products/ERP5SyncML: ./ Conduit/ dtml/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Aug 10 09:49:11 CEST 2007


Author: nicolas
Date: Fri Aug 10 09:49:11 2007
New Revision: 15587

URL: http://svn.erp5.org?rev=15587&view=rev
Log:
Add log management, optimisation, typo

Modified:
    erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
    erp5/trunk/products/ERP5SyncML/Publication.py
    erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py
    erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py
    erp5/trunk/products/ERP5SyncML/SyncCode.py
    erp5/trunk/products/ERP5SyncML/XupdateUtils.py
    erp5/trunk/products/ERP5SyncML/dtml/manageSubscriptions.dtml
    erp5/trunk/products/ERP5SyncML/dtml/manage_addSubscription.dtml

Modified: erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py (original)
+++ erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py Fri Aug 10 09:49:11 2007
@@ -48,7 +48,7 @@
 import re, copy
 import cStringIO
 
-from zLOG import LOG
+from zLOG import LOG, INFO, DEBUG
 try:
   from Ft.Xml.Domlette import Print, PrettyPrint
 except ImportError:
@@ -180,10 +180,9 @@
          and self.getSubObjectDepth(xml)>=1:
       sub_object_id = self.getSubObjectId(xml)
       if previous_xml is not None and sub_object_id is not None:
-        #LOG('addNode',0,'previous xml is not none and also sub_object_id')
         # Find the previous xml corresponding to this subobject
-        sub_previous_xml = self.getSubObjectXml(sub_object_id,previous_xml)
-        #LOG('addNode',0,'isSubObjectModification sub_p_xml: %s' % str(sub_previous_xml))
+        sub_previous_xml = self.getSubObjectXml(sub_object_id, previous_xml)
+        LOG('addNode', DEBUG,'isSubObjectModification sub_previous_xml: %s' % str(sub_previous_xml))
         if sub_previous_xml is not None:
           sub_object = None
           try:
@@ -191,11 +190,11 @@
           except (AttributeError, KeyError, TypeError):
             pass
           if sub_object is not None:
-            #LOG('addNode',0,'subobject.id: %s' % sub_object.id)
+            LOG('addNode', DEBUG, 'subobject.id: %s' % sub_object.id)
             # Change the xml in order to directly apply
             # modifications to the subobject
             sub_xml = self.getSubObjectXupdate(xml)
-            #LOG('addNode',0,'sub_xml: %s' % str(sub_xml))
+            LOG('addNode', DEBUG, 'sub_xml: %s' % str(sub_xml))
             # Then do the udpate
             conflict_list += self.addNode(xml=sub_xml,object=sub_object,
                             previous_xml=sub_previous_xml, force=force,
@@ -220,14 +219,12 @@
     A node is deleted
     """
     # In the case where we have to delete an object
-    #LOG('ERP5Conduit',0,'deleteNode')
-    #LOG('ERP5Conduit',0,'deleteNode, object.id: %s' % object.getId())
-    #LOG('ERP5Conduit',0,'deleteNode, object path: %s' % repr(object.getPhysicalPath()))
+    LOG('ERP5Conduit.deleteNode', DEBUG, 'deleteNode, object path: %s' % repr(object.getPhysicalPath()))
     conflict_list = []
     if xml is not None:
       xml = self.convertToXml(xml)
     if object_id is None:
-      #LOG('ERP5Conduit',0,'deleteNode, SubObjectDepth: %i' % self.getSubObjectDepth(xml))
+      LOG('ERP5Conduit.deleteNode', DEBUG, 'deleteNode, SubObjectDepth: %i' % self.getSubObjectDepth(xml))
       if xml.nodeName == self.xml_object_tag:
         object_id = self.getAttribute(xml,'id')
       elif self.getSubObjectDepth(xml)==1:
@@ -241,7 +238,7 @@
           conflict_list += self.deleteNode(xml=sub_xml,object=sub_object,
                                        force=force, simulate=simulate, **kw)
         except (KeyError, AttributeError, TypeError):
-          #LOG('ERP5Conduit',0,'deleteNode, Unable to delete SubObject: %s' % str(sub_object_id))
+          LOG('ERP5Conduit.deleteNode', DEBUG, 'deleteNode, Unable to delete SubObject: %s' % str(sub_object_id))
           pass
     if object_id is not None: # We do have an object_id
       self.deleteObject(object, object_id)
@@ -252,7 +249,7 @@
       if xml.nodeName in self.local_role_list and not simulate:
         # We want to del a local role
         user = self.getAttribute(xml,'id')
-        #LOG('local_role: ',0,'user: %s' % repr(user))
+        LOG('ERP5Conduit.deleteNode local_role: ', DEBUG, 'user: %s' % repr(user))
         if xml.nodeName.find(self.local_role_tag)>=0:
           object.manage_delLocalRoles([user])
         elif xml.nodeName.find(self.local_group_tag)>=0:
@@ -267,7 +264,7 @@
     try:
       object._delObject(object_id)
     except (AttributeError, KeyError):
-      #LOG('ERP5Conduit',0,'deleteObject, Unable to delete: %s' % str(object_id))
+      LOG('ERP5Conduit.deleteObject', DEBUG, 'Unable to delete: %s' % str(object_id))
       pass
 
   security.declareProtected(Permissions.ModifyPortalContent, 'updateNode')
@@ -282,8 +279,8 @@
     """
     conflict_list = []
     xml = self.convertToXml(xml)
-    #LOG('updateNode',0,'xml.nodeName: %s' % xml.nodeName)
-    #LOG('updateNode, force: ',0,force)
+    LOG('ERP5Conduit.updateNode', DEBUG, 'xml.nodeName: %s' % xml.nodeName)
+    LOG('ERP5Conduit.updateNode, force: ', DEBUG, force)
     # we have an xupdate xml
     if xml.nodeName == 'xupdate:modifications':
       conflict_list += self.applyXupdate(object=object, xupdate=xml, 
@@ -292,12 +289,10 @@
     # we may have only the part of an xupdate
     else:
       args = {}
-      #LOG('isSubObjectModification',0,'result: %s' % str(self.isSubObjectModification(xml)))
       if self.isProperty(xml) and not(self.isSubObjectModification(xml)):
         keyword = None
         for subnode in self.getAttributeNodeList(xml):
           if subnode.nodeName=='select':
-            #LOG('updateNode',0,'selection: %s' % str(subnode.nodeValue))
             select_list = subnode.nodeValue.split('/') # Something like:
                                                        #('','object[1]','sid[1]')
             new_select_list = ()
@@ -309,7 +304,6 @@
             keyword = select_list[len(select_list)-1] # this will be 'sid'
         data_xml = xml
         data = None
-        #LOG('updateNode',0,'keyword: %s' % str(keyword))
         if xml.nodeName not in self.XUPDATE_INSERT_OR_ADD:
           for subnode in self.getElementNodeList(xml):
             if subnode.nodeName=='xupdate:element':
@@ -343,7 +337,7 @@
         if not (keyword in self.NOT_EDITABLE_PROPERTY):
           # We will look for the data to enter
           data_type = object.getPropertyType(keyword)
-          #LOG('updateNode',0,'data_type: %s' % str(data_type))
+          LOG('ERP5Conduit.updateNode', DEBUG, 'data_type: %s for keyword: %s' % (str(data_type), keyword))
           data = self.convertXmlValue(data,data_type=data_type)
           args[keyword] = data
           args = self.getFormatedArgs(args=args)
@@ -358,12 +352,12 @@
                 data_type=data_type)
             #current_data = object.getProperty(keyword)
             current_data = self.getProperty(object, keyword)
-            #LOG('updateNode',0,'Conflict data: %s' % str(data))
-            #LOG('updateNode',0,'Conflict old_data: %s' % str(old_data))
-            #LOG('updateNode',0,'Conflict current_data: %s' % str(current_data))
+            LOG('ERP5Conduit.updateNode', DEBUG, 'Conflict data: %s' % str(data))
+            LOG('ERP5Conduit.updateNode', DEBUG, 'Conflict old_data: %s' % str(old_data))
+            LOG('ERP5Conduit.updateNode', DEBUG, 'Conflict current_data: %s' % str(current_data))
             if (old_data != current_data) and (data != current_data) \
                 and keyword not in self.force_conflict_list:
-              #LOG('updateNode',0,'Conflict on : %s' % keyword)
+              LOG('ERP5Conduit.updateNode', DEBUG, 'Conflict on : %s' % keyword)
               # Hack in order to get the synchronization working for demo
               # XXX this have to be removed after
               #if not (data_type in self.binary_type_list):
@@ -379,11 +373,6 @@
                   conflict.setLocalValue(current_data)
                   conflict.setRemoteValue(data)
                 conflict_list += [conflict]
-                #conflict_list += [Conflict(object_path=object.getPhysicalPath(),
-                #                           keyword=keyword,
-                #                           xupdate=string_io)]
-                                           #publisher_value=current_data, # not needed any more
-                                           #subscriber_value=data)] # not needed any more
           # We will now apply the argument with the method edit
           if args != {} and (isConflict==0 or force) and (not simulate):
             self.editDocument(object=object,**args)
@@ -399,9 +388,9 @@
           # This is the case where we have to call addNode
           conflict_list += self.addNode(xml=subnode,object=object,force=force,
               simulate=simulate,**kw)['conflict_list']
-        elif keyword in (self.local_role_tag,self.local_permission_tag) and not simulate:
+        elif keyword in (self.local_role_tag, self.local_permission_tag) and not simulate:
           # This is the case where we have to update Roles or update permission
-          #LOG('updateNode',0,'we will add a local role')
+          #LOG('ERP5Conduit.updateNode', DEBUG, 'we will add a local role')
           #user = self.getSubObjectId(xml)
           #roles = self.convertXmlValue(data,data_type='tokens')
           #object.manage_setLocalRoles(user,roles)
@@ -412,11 +401,10 @@
         # We should find the object corresponding to
         # this update, so we have to look in the previous_xml
         sub_object_id = self.getSubObjectId(xml)
-        #LOG('updateNode',0,'isSubObjectModification sub_object_id: %s' % sub_object_id)
+        LOG('ERP5Conduit.updateNode', DEBUG,'isSubObjectModification sub_object_id: %s' % sub_object_id)
         if previous_xml is not None and sub_object_id is not None:
-          #LOG('updateNode',0,'previous xml is not none and also sub_object_id')
           sub_previous_xml = self.getSubObjectXml(sub_object_id,previous_xml)
-          #LOG('updateNode',0,'isSubObjectModification sub_p_xml: %s' % str(sub_previous_xml))
+          LOG('ERP5Conduit.updateNode', DEBUG, 'isSubObjectModification sub_previous_xml: %s' % str(sub_previous_xml))
           if sub_previous_xml is not None:
             sub_object = None
             try:
@@ -424,11 +412,11 @@
             except KeyError:
               pass
             if sub_object is not None:
-              #LOG('updateNode',0,'subobject.id: %s' % sub_object.id)
+              LOG('ERP5Conduit.updateNode', DEBUG, 'subobject.id: %s' % sub_object.id)
               # Change the xml in order to directly apply
               # modifications to the subobject
               sub_xml = self.getSubObjectXupdate(xml)
-              #LOG('updateNode',0,'sub_xml: %s' % str(sub_xml))
+              LOG('ERP5Conduit.updateNode', DEBUG, 'sub_xml: %s' % str(sub_xml))
               # Then do the udpate
               conflict_list += self.updateNode(xml=sub_xml, object=sub_object, 
                   force=force, previous_xml=sub_previous_xml, 
@@ -485,7 +473,7 @@
         data = data.encode(self.getEncoding())
         data = data.replace('@@@','\n')
       if keyword == 'binary_data':
-        #LOG('ERP5Conduit.getFormatedArgs',0,'binary_data keyword: %s' % str(keyword))
+        LOG('ERP5Conduit.getFormatedArgs', DEBUG, 'binary_data keyword: %s' % str(keyword))
         msg = MIMEBase('application','octet-stream')
         Encoders.encode_base64(msg)
         msg.set_payload(data)

Modified: erp5/trunk/products/ERP5SyncML/Publication.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Publication.py?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Publication.py (original)
+++ erp5/trunk/products/ERP5SyncML/Publication.py Fri Aug 10 09:49:11 2007
@@ -95,7 +95,7 @@
         Add a new Category and generate UID by calling the
         ZSQLCatalog
     """
-    o = Publication( id ,'','','','','')
+    o = Publication( id, '', '', '', '', '')
     self._setObject( id, o )
     if REQUEST is not None:
         return self.manage_main(self, REQUEST, update_menu=1)
@@ -143,9 +143,9 @@
 
   # Constructor
   def __init__(self, id, title, publication_url, destination_path,
-      source_uri, query, xml_mapping, conduit, gpg_key, id_generator, 
-      gid_generator, media_type, auth_required, authentication_format, 
-      authentication_type, activity_enabled, synchronize_with_erp5_sites, 
+      source_uri, query, xml_mapping, conduit, gpg_key, id_generator,
+      gid_generator, media_type, auth_required, authentication_format,
+      authentication_type, activity_enabled, synchronize_with_erp5_sites,
       sync_content_type):
     """
       constructor
@@ -157,7 +157,6 @@
     self.setSourceURI(source_uri)
     self.setQuery(query)
     self.xml_mapping = xml_mapping
-    #self.list_subscribers = PersistentMapping()
     self.domain_type = self.PUB
     self.gpg_key = gpg_key
     self.setGidGenerator(gid_generator)
@@ -231,48 +230,46 @@
     """
       Add a new subscriber to the publication
     """
-    LOG('addSubscriber starting ...',0,'')
     # We have to remove the subscriber if it already exist (there were probably a reset on the client)
     self.delSubscriber(subscriber.getSubscriptionUrl())
     new_id = subscriber.getId()
     if new_id is None:
       new_id = str(self.generateNewId())
     subscriber.id = new_id
-    #if len(self.list_subscribers) == 0:
-    #  self.list_subscribers = []
-    #self.list_subscribers = self.list_subscribers + [subscriber]
-    self._setObject(new_id,subscriber)
+    self._setObject(new_id, subscriber)
 
   def getSubscriber(self, subscription_url):
     """
       return the subscriber corresponding the to subscription_url
     """
-    for o in self.objectValues():
+    o = None
+    for sub in self.getSubscriberList():
+      if sub.getSubscriptionUrl() == subscription_url:
+        o = sub
+        break
+    return o
+
+  def getSubscriberList(self):
+    """
+      Get the list of subscribers
+    """
+    return self.objectValues()
+
+
+  def delSubscriber(self, subscription_url):
+    """
+      Delete a subscriber for this publication
+    """
+    for o in self.getSubscriberList():
       if o.getSubscriptionUrl() == subscription_url:
-        return o
-    return None
-
-  def getSubscriberList(self):
-    """
-      Get the list of subscribers
-    """
-    return self.objectValues()
-
-
-  def delSubscriber(self, subscription_url):
-    """
-      Delete a subscriber for this publication
-    """
-    for o in self.objectValues():
-      if o.getSubscriptionUrl() == subscription_url:
-        self._delObject(o.id)
+        self.activate().manage_delObjects(o.id)
 
   def resetAllSubscribers(self):
     """
       Reset all subscribers
     """
-    for o in self.objectValues():
-      self._delObject(o.id)
+    for o in self.getSubscriberList():
+      self.activate().manage_delObjects(o.id)
 
   def getConflictList(self):
     """
@@ -280,6 +277,6 @@
     """
     conflict_list = []
     for subscriber in self.getSubscriberList():
-      conflict_list += subscriber.getConflictList()
+      conflict_list.extend(subscriber.getConflictList())
     return conflict_list
 

Modified: erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py (original)
+++ erp5/trunk/products/ERP5SyncML/PublicationSynchronization.py Fri Aug 10 09:49:11 2007
@@ -39,11 +39,11 @@
 from AccessControl.SecurityManagement import newSecurityManager
 import commands
 from DateTime import DateTime
-from zLOG import LOG
+from zLOG import LOG, DEBUG, INFO, WARNING
 
 class PublicationSynchronization(XMLSyncUtils):
   """
-    
+    Receive the first XML message from the client
   """
 
   def PubSyncInit(self, publication=None, xml_client=None, subscriber=None, 
@@ -52,8 +52,7 @@
       Read the client xml message
       Send the first XML message from the server
     """
-    LOG('PubSyncInit',0,'Starting... publication: %s' % str(publication))
-    
+    LOG('PubSyncInit', DEBUG, 'Starting... publication: %s' % (publication.getPath()))
     #the session id is set at the same value of those of the client
     subscriber.setSessionId(self.getSessionId(xml_client))
     #same for the message id
@@ -80,8 +79,8 @@
 
       # If slow sync, then resend everything
       if alert_code == self.SLOW_SYNC:
-        LOG('Warning !!!, reseting client synchronization for subscriber:',0,
-            subscriber)
+        LOG('Warning !!!, reseting client synchronization for subscriber:', WARNING,
+            subscriber.getPath())
         subscriber.resetAllSignatures()
 
       # Check if the last time synchronization is the same as the client one
@@ -89,16 +88,12 @@
         \nlast_anchor:\t\t\t%s\nnext_anchor:\t\t\t%s' % \
         (subscriber.getNextAnchor(), subscriber.getLastAnchor(), last_anchor, \
         next_anchor)
-      #LOG('PubSyncInit',0,mess)
-      
       if subscriber.getNextAnchor() != last_anchor:
         if last_anchor in (None, ''):
-          LOG('PubSyncInit',0,'anchor null')
-          #raise ValueError, "Sorry, the anchor was null"
+          LOG('PubSyncInit', DEBUG, 'anchor null')
         else:
           message = "bad anchors in PubSyncInit! " + \
               subscriber.getNextAnchor() + " and " + last_anchor
-          LOG('PubSyncInit',0,message)
       else:
         subscriber.setNextAnchor(next_anchor)
 
@@ -118,14 +113,14 @@
       if publication.isAuthenticationRequired():
         #at the begining, the code is initialised at UNAUTHORIZED
         auth_code=self.UNAUTHORIZED
-        LOG('PubSyncInit',0,'authentication required')
+        LOG('PubSyncInit', INFO, 'authentication required')
         if not cred:
           auth_code=self.AUTH_REQUIRED
-          LOG("there's no credential !!!",0,'')
+          LOG("PubSyncInit there's no credential !!!", INFO,'')
 	        # Prepare the xml message for the Sync initialization package
-          xml(self.SyncMLChal(cmd_id, "SyncHdr", 
-            publication.getPublicationUrl(), subscriber.getSubscriptionUrl(), 
-            publication.getAuthenticationFormat(), 
+          xml(self.SyncMLChal(cmd_id, "SyncHdr",
+            publication.getPublicationUrl(), subscriber.getSubscriptionUrl(),
+            publication.getAuthenticationFormat(),
             publication.getAuthenticationType(), auth_code))
           cmd_id += 1
 	        # chal message
@@ -154,8 +149,7 @@
                   break
                 else:
                   auth_code=self.UNAUTHORIZED
-          #in all others cases, the auth_code is set to UNAUTHORIZED  
-
+          #in all others cases, the auth_code is set to UNAUTHORIZED
 
           # Prepare the xml message for the Sync initialization package
           if auth_code == self.AUTH_ACCEPTED:
@@ -163,25 +157,25 @@
                 cmd_id, next_anchor, subscription=subscriber).values()
             xml(xml_status)
             # alert message
-            xml(self.SyncMLAlert(cmd_id, sync_type, subscriber.getTargetURI(), 
-              subscriber.getSourceURI(), subscriber.getLastAnchor(), 
+            xml(self.SyncMLAlert(cmd_id, sync_type, subscriber.getTargetURI(),
+              subscriber.getSourceURI(), subscriber.getLastAnchor(),
               next_anchor))
             cmd_id += 1
           else:
 	          # chal message
-            xml(self.SyncMLChal(cmd_id, "SyncHdr", 
-              publication.getPublicationUrl(), subscriber.getSubscriptionUrl(), 
-              publication.getAuthenticationFormat(), 
+            xml(self.SyncMLChal(cmd_id, "SyncHdr",
+              publication.getPublicationUrl(), subscriber.getSubscriptionUrl(),
+              publication.getAuthenticationFormat(),
               publication.getAuthenticationType(), auth_code))
             cmd_id += 1
-            xml_status, cmd_id = self.SyncMLStatus(xml_client, 
-                self.AUTH_REQUIRED, cmd_id, next_anchor, 
+            xml_status, cmd_id = self.SyncMLStatus(xml_client,
+                self.AUTH_REQUIRED, cmd_id, next_anchor,
                 subscription=subscriber).values()
             xml(xml_status)
 
       elif alert is not None: #if no identification is required :
         # syncml header
-        xml_status, cmd_id = self.SyncMLStatus(xml_client, self.AUTH_ACCEPTED, 
+        xml_status, cmd_id = self.SyncMLStatus(xml_client, self.AUTH_ACCEPTED,
             cmd_id, next_anchor, subscription=subscriber).values()
         xml(xml_status)
         # alert message
@@ -203,28 +197,27 @@
     xml(' </SyncBody>\n')
     xml('</SyncML>\n')
     xml_a = ''.join(xml_list)
-    
     if publication.getSyncContentType() == self.CONTENT_TYPE['SYNCML_WBXML']:
       xml_a = self.xml2wbxml(xml_a)
     self.sendResponse(from_url=publication.getPublicationUrl(),
-      to_url=subscriber.getSubscriptionUrl(), sync_id=publication.getTitle(), 
-      xml=xml_a, domain=publication, 
+      to_url=subscriber.getSubscriptionUrl(), sync_id=publication.getTitle(),
+      xml=xml_a, domain=publication,
       content_type=publication.getSyncContentType())
 
-    return {'has_response':1,'xml':xml_a}
+    return {'has_response':1, 'xml':xml_a}
 
 
   def PubSync(self, publication_path, msg=None, RESPONSE=None, subscriber=None):
     """
       This is the synchronization method for the server
     """
-    LOG('PubSync',0,'Starting... publication: %s' % str(publication_path))
+    LOG('PubSync', DEBUG, 'Starting... publication: %s' % (publication_path))
     # Read the request from the client
     publication = self.unrestrictedTraverse(publication_path)
     xml_client = msg
     if xml_client is None:
       xml_client = self.readResponse(from_url=publication.getPublicationUrl())
-    #LOG('PubSync',0,'Starting... msg: %s' % str(xml_client))
+    LOG('PubSync', DEBUG, 'Starting... msg: %s' % str(xml_client))
     result = None
 
     if xml_client is not None:
@@ -233,14 +226,13 @@
       first_node = xml_client.childNodes[0]
 
       if first_node.nodeName != "SyncML":
-        #LOG('PubSync',0,'This is not a SyncML Message')
+        LOG('PubSync', INFO, 'This is not a SyncML Message')
         raise ValueError, "Sorry, This is not a SyncML Message"
       alert_code = self.getAlertCode(xml_client)
-      
       # Get informations from the header
       client_header = first_node.childNodes[1]
       if client_header.nodeName != "SyncHdr":
-        #LOG('PubSync',0,'This is not a SyncML Header')
+        LOG('PubSync', INFO, 'This is not a SyncML Header')
         raise ValueError, "Sorry, This is not a SyncML Header"
       subscription_url = self.getSubscriptionUrl(client_header)
       # Get the subscriber or create it if not already in the list
@@ -272,8 +264,8 @@
     elif subscriber is not None:
       # This looks like we are starting a synchronization after
       # a conflict resolution by the user
-      result = self.PubSyncInit(publication=publication, xml_client=None, 
-          subscriber=subscriber,sync_type=self.TWO_WAY)
+      result = self.PubSyncInit(publication=publication, xml_client=None,
+          subscriber=subscriber, sync_type=self.TWO_WAY)
 
     if RESPONSE is not None:
       RESPONSE.redirect('managePublications')
@@ -284,4 +276,4 @@
     """
     The modidification message for the publication
     """
-    return self.SyncModif(publication,xml_client)
+    return self.SyncModif(publication, xml_client)

Modified: erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py (original)
+++ erp5/trunk/products/ERP5SyncML/SubscriptionSynchronization.py Fri Aug 10 09:49:11 2007
@@ -32,7 +32,7 @@
 import commands
 from Conduit.ERP5Conduit import ERP5Conduit
 from DateTime import DateTime
-from zLOG import LOG
+from zLOG import LOG, DEBUG, INFO
 
 class SubscriptionSynchronization(XMLSyncUtils):
 
@@ -48,8 +48,8 @@
     xml = xml_list.append
     xml('<SyncML>\n')
     # syncml header
-    xml(self.SyncMLHeader(subscription.incrementSessionId(), 
-      subscription.incrementMessageId(), subscription.getPublicationUrl(), 
+    xml(self.SyncMLHeader(subscription.incrementSessionId(),
+      subscription.incrementMessageId(), subscription.getPublicationUrl(),
       subscription.getSubscriptionUrl(), source_name=subscription.getLogin()))
 
     # syncml body
@@ -62,7 +62,7 @@
     xml(self.SyncMLAlert(cmd_id, subscription.getSynchronizationType(),
                             subscription.getTargetURI(),
                             subscription.getSourceURI(),
-                            subscription.getLastAnchor(), 
+                            subscription.getLastAnchor(),
                             subscription.getNextAnchor()))
     cmd_id += 1
     syncml_put = self.SyncMLPut(cmd_id, subscription)
@@ -74,9 +74,9 @@
     xml_a = ''.join(xml_list)
 
     self.sendResponse(from_url=subscription.subscription_url,
-        to_url=subscription.publication_url, sync_id=subscription.getTitle(), 
-        xml=xml_a,domain=subscription, 
-        content_type=subscription.getSyncContentType()) 
+        to_url=subscription.publication_url, sync_id=subscription.getTitle(),
+        xml=xml_a,domain=subscription,
+        content_type=subscription.getSyncContentType())
 
     return {'has_response':1,'xml':xml_a}
 
@@ -87,7 +87,7 @@
     response = None #check if subsync replies to this messages
     subscription = self.unrestrictedTraverse(subscription_path)
     if msg==None and (subscription.getSubscriptionUrl()).find('file')>=0:
-      msg = self.readResponse(sync_id=subscription.getSubscriptionUrl(), 
+      msg = self.readResponse(sync_id=subscription.getSubscriptionUrl(),
           from_url=subscription.getSubscriptionUrl())
     if msg==None:
       response = self.SubSyncInit(subscription)
@@ -100,11 +100,11 @@
           status_code_syncHdr = status_list[0]['code']
           if status_code_syncHdr.isdigit():
             status_code_syncHdr = int(status_code_syncHdr)
-          #LOG('readResponse status code :',0,status_code_syncHdr)
+          LOG('SubSync status code : ', DEBUG, status_code_syncHdr)
           if status_code_syncHdr == self.AUTH_REQUIRED:
             if self.checkChal(xml_client):
               authentication_format, authentication_type = self.getChal(xml_client)
-              #LOG('auth_required :',0, 'format:%s, type:%s' % (authentication_format, authentication_type))
+              LOG('SubSync auth_required :', DEBUG, 'format:%s, type:%s' % (authentication_format, authentication_type))
               if authentication_format is not None and \
                   authentication_type is not None:
                 subscription.setAuthenticationFormat(authentication_format)
@@ -113,14 +113,14 @@
               raise ValueError, "Sorry, the server chalenge for an \
                   authentication, but the authentication format is not find"
 
-            #LOG('readResponse', 0, 'Authentication required')
+            LOG('SubSync', INFO, 'Authentication required')
             response = self.SubSyncCred(subscription, xml_client)
           elif status_code_syncHdr == self.UNAUTHORIZED:
-            LOG('readResponse', 0, 'Bad authentication')
-            return {'has_response':0,'xml':xml_client}
+            LOG('SubSync', INFO, 'Bad authentication')
+            return {'has_response':0, 'xml':xml_client}
           else:
             response = self.SubSyncModif(subscription, xml_client)
-        else: 
+        else:
             response = self.SubSyncModif(subscription, xml_client)
 
     if RESPONSE is not None:
@@ -141,12 +141,12 @@
     data=subscription.encode(subscription.getAuthenticationFormat(), data)
     xml(self.SyncMLHeader(
       subscription.incrementSessionId(),
-      subscription.incrementMessageId(), 
+      subscription.incrementMessageId(),
       subscription.getPublicationUrl(),
-      subscription.getSubscriptionUrl(), 
-      source_name=subscription.getLogin(), 
+      subscription.getSubscriptionUrl(),
+      source_name=subscription.getLogin(),
       dataCred=data, 
-      authentication_format=subscription.getAuthenticationFormat(), 
+      authentication_format=subscription.getAuthenticationFormat(),
       authentication_type=subscription.getAuthenticationType()))
 
     # syncml body
@@ -174,7 +174,7 @@
         xml=xml_a,domain=subscription,
         content_type=subscription.getSyncContentType())
 
-    return {'has_response':1,'xml':xml_a}
+    return {'has_response':1, 'xml':xml_a}
 
   def SubSyncModif(self, subscription, xml_client):
     """

Modified: erp5/trunk/products/ERP5SyncML/SyncCode.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SyncCode.py?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SyncCode.py (original)
+++ erp5/trunk/products/ERP5SyncML/SyncCode.py Fri Aug 10 09:49:11 2007
@@ -40,6 +40,7 @@
   ONE_WAY_FROM_SERVER = 204
   WAITING_DATA = 214
   REFRESH_REQUIRED = 508
+  CODE_LIST = ( TWO_WAY, ONE_WAY_FROM_SERVER )
 
   # SyncML Status Codes
   SUCCESS = 200

Modified: erp5/trunk/products/ERP5SyncML/XupdateUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/XupdateUtils.py?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/XupdateUtils.py (original)
+++ erp5/trunk/products/ERP5SyncML/XupdateUtils.py Fri Aug 10 09:49:11 2007
@@ -48,7 +48,7 @@
     for subnode in self.getElementNodeList(xupdate):
       selection_name = ''
       if subnode.nodeName in self.XUPDATE_INSERT_OR_ADD:
-        conflict_list += conduit.addNode(xml=subnode,object=object, \
+        conflict_list += conduit.addNode(xml=subnode, object=object, \
                                          force=force, **kw)
       elif subnode.nodeName in self.XUPDATE_DEL:
         conflict_list += conduit.deleteNode(xml=subnode, object=object, \
@@ -56,9 +56,6 @@
       elif subnode.nodeName in self.XUPDATE_UPDATE:
         conflict_list += conduit.updateNode(xml=subnode, object=object, \
                                          force=force, **kw)
-      #elif subnode.nodeName in self.XUPDATE_INSERT:
-      #  conflict_list += conduit.addNode(xml=subnode, object=object, force=force, **kw)
-
     return conflict_list
 
 

Modified: erp5/trunk/products/ERP5SyncML/dtml/manageSubscriptions.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/dtml/manageSubscriptions.dtml?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/dtml/manageSubscriptions.dtml (original)
+++ erp5/trunk/products/ERP5SyncML/dtml/manageSubscriptions.dtml Fri Aug 10 09:49:11 2007
@@ -66,12 +66,13 @@
         </label></div>
         </td>
         <td align="left" valign="top">
-        <select name="alert_code">
-          <dtml-in getAlertCodeList>
-            <dtml-let item=sequence-item>
-            <option value="<dtml-var item>"  <dtml-if expr="getAlertCode() == str(item)">SELECTED</dtml-if>><dtml-var item></option>
-            </dtml-let>
-          </dtml-in>
+          <select name="alert_code">
+            <dtml-in getAlertCodeList>
+              <dtml-let item=sequence-item>
+                <option value="<dtml-var item>"  <dtml-if expr="getAlertCode() == item">SELECTED</dtml-if>><dtml-var item></option>
+              </dtml-let>
+            </dtml-in>
+          </select>
         </td>
       </tr>
       <tr>

Modified: erp5/trunk/products/ERP5SyncML/dtml/manage_addSubscription.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/dtml/manage_addSubscription.dtml?rev=15587&r1=15586&r2=15587&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/dtml/manage_addSubscription.dtml (original)
+++ erp5/trunk/products/ERP5SyncML/dtml/manage_addSubscription.dtml Fri Aug 10 09:49:11 2007
@@ -147,7 +147,7 @@
     </label></div>
     </td>
     <td align="left" valign="top">
-      <input type="checkbox" name="synchronize_with_erp5_sites" value="1">
+      <input type="checkbox" name="synchronize_with_erp5_sites" value="1" checked="checked">
     </td>
   </tr>
   <tr>




More information about the Erp5-report mailing list