[Erp5-report] r14699 - /erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jun 6 10:00:03 CEST 2007


Author: nicolas
Date: Wed Jun  6 10:00:03 2007
New Revision: 14699

URL: http://svn.erp5.org?rev=14699&view=rev
Log:
hide logs

Modified:
    erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py

Modified: erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py?rev=14699&r1=14698&r2=14699&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py (original)
+++ erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py Wed Jun  6 10:00:03 2007
@@ -139,7 +139,7 @@
     xml = self.convertToXml(xml)
     if xml is None:
       return {'conflict_list':conflict_list, 'object':sub_object}
-    LOG('addNode',0,'xml_reconstitued: %s' % str(xml))
+    #LOG('addNode',0,'xml_reconstitued: %s' % str(xml))
     # In the case where this new node is a object to add
     if xml.nodeName in self.XUPDATE_INSERT_OR_ADD and \
         self.getSubObjectDepth(xml)==0:
@@ -153,7 +153,7 @@
       if object_id is None:
         object_id = self.getAttribute(xml,'id')
       docid = self.getObjectDocid(xml)
-      LOG('addNode',0,'object_id: %s' % object_id)
+      #LOG('addNode',0,'object_id: %s' % object_id)
       if object_id is not None:
         if sub_object is None:
           try:
@@ -181,12 +181,12 @@
     elif xml.nodeName in self.XUPDATE_INSERT_OR_ADD \
          and self.getSubObjectDepth(xml)>=1:
       sub_object_id = self.getSubObjectId(xml)
-      LOG('addNode',0,'getSubObjectModification number: %s' % sub_object_id)
+      #LOG('addNode',0,'getSubObjectModification number: %s' % sub_object_id)
       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')
+        #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))
+        #LOG('addNode',0,'isSubObjectModification sub_p_xml: %s' % str(sub_previous_xml))
         if sub_previous_xml is not None:
           sub_object = None
           try:
@@ -194,11 +194,11 @@
           except (AttributeError, KeyError, TypeError):
             pass
           if sub_object is not None:
-            LOG('addNode',0,'subobject.id: %s' % sub_object.id)
+            #LOG('addNode',0,'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',0,'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,
@@ -223,14 +223,14 @@
     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',0,'deleteNode')
+    #LOG('ERP5Conduit',0,'deleteNode, object.id: %s' % object.getId())
+    #LOG('ERP5Conduit',0,'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',0,'deleteNode, SubObjectDepth: %i' % self.getSubObjectDepth(xml))
       if xml.nodeName == self.xml_object_tag:
         object_id = self.getAttribute(xml,'id')
       elif self.getSubObjectDepth(xml)==1:
@@ -244,13 +244,13 @@
           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',0,'deleteNode, Unable to delete SubObject: %s' % str(sub_object_id))
           pass
     if object_id is not None: # We do have an object_id
       try:
         object._delObject(object_id)
       except (AttributeError, KeyError):
-        LOG('ERP5Conduit',0,'deleteNode, Unable to delete: %s' % str(object_id))
+        #LOG('ERP5Conduit',0,'deleteNode, Unable to delete: %s' % str(object_id))
         pass
     # In the case where we have to delete an user role
     # If we are still there, this means the delete is for this node
@@ -259,7 +259,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('local_role: ',0,'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:
@@ -281,8 +281,8 @@
     """
     conflict_list = []
     xml = self.convertToXml(xml)
-    LOG('updateNode',0,'xml.nodeName: %s' % xml.nodeName)
-    LOG('updateNode, force: ',0,force)
+    #LOG('updateNode',0,'xml.nodeName: %s' % xml.nodeName)
+    #LOG('updateNode, force: ',0,force)
     # we have an xupdate xml
     if xml.nodeName == 'xupdate:modifications':
       conflict_list += self.applyXupdate(object=object, xupdate=xml, 
@@ -291,12 +291,12 @@
     # we may have only the part of an xupdate
     else:
       args = {}
-      LOG('isSubObjectModification',0,'result: %s' % str(self.isSubObjectModification(xml)))
+      #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))
+            #LOG('updateNode',0,'selection: %s' % str(subnode.nodeValue))
             select_list = subnode.nodeValue.split('/') # Something like:
                                                        #('','object[1]','sid[1]')
             new_select_list = ()
@@ -308,7 +308,7 @@
             keyword = select_list[len(select_list)-1] # this will be 'sid'
         data_xml = xml
         data = None
-        LOG('updateNode',0,'keyword: %s' % str(keyword))
+        #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':
@@ -342,7 +342,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('updateNode',0,'data_type: %s' % str(data_type))
           data = self.convertXmlValue(data,data_type=data_type)
           args[keyword] = data
           args = self.getFormatedArgs(args=args)
@@ -357,12 +357,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('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))
             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('updateNode',0,'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):
@@ -385,7 +385,7 @@
                                            #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):
-            LOG('updateNode',0,'object._edit, args: %s' % str(args))
+            #LOG('updateNode',0,'object._edit, args: %s' % str(args))
             #object._edit(**args)
             self.editDocument(object=object,**args)
             # It is sometimes required to do something after an edit
@@ -394,17 +394,17 @@
 
         if keyword == 'object':
           # This is the case where we have to call addNode
-          LOG('updateNode',0,'we will add sub-object')
+          #LOG('updateNode',0,'we will add sub-object')
           conflict_list += self.addNode(xml=xml, object=object, force=force, 
               simulate=simulate, **kw)['conflict_list']
         elif keyword == self.history_tag and not simulate:
           # This is the case where we have to call addNode
-          LOG('updateNode',0,'we will add history')
+          #LOG('updateNode',0,'we will add history')
           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:
           # This is the case where we have to update Roles or update permission
-          LOG('updateNode',0,'we will add a local role')
+          #LOG('updateNode',0,'we will add a local role')
           #user = self.getSubObjectId(xml)
           #roles = self.convertXmlValue(data,data_type='tokens')
           #object.manage_setLocalRoles(user,roles)
@@ -415,11 +415,11 @@
         # 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('updateNode',0,'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')
+          #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('updateNode',0,'isSubObjectModification sub_p_xml: %s' % str(sub_previous_xml))
           if sub_previous_xml is not None:
             sub_object = None
             try:
@@ -427,11 +427,11 @@
             except KeyError:
               pass
             if sub_object is not None:
-              LOG('updateNode',0,'subobject.id: %s' % sub_object.id)
+              #LOG('updateNode',0,'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('updateNode',0,'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, simulate=simulate, **kw)
@@ -470,7 +470,7 @@
     This lookd inside the args dictionnary and then
     convert any unicode string to string
     """
-    LOG('ERP5Conduit.getFormatedArgs',0,'args: %s' % str(args))
+    #LOG('ERP5Conduit.getFormatedArgs',0,'args: %s' % str(args))
     new_args = {}
     for keyword in args.keys():
       data = args[keyword]
@@ -488,7 +488,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',0,'binary_data keyword: %s' % str(keyword))
         msg = MIMEBase('application','octet-stream')
         Encoders.encode_base64(msg)
         msg.set_payload(data)
@@ -562,17 +562,17 @@
     1 means it is a subobject
     2 means it is more depth than subobject
     """
-    LOG('getSubObjectDepth',0,'xml.nodeName: %s' % xml.nodeName)
+    #LOG('getSubObjectDepth',0,'xml.nodeName: %s' % xml.nodeName)
     if xml.nodeName in self.XUPDATE_TAG:
       i = 0
       if xml.nodeName in self.XUPDATE_INSERT:
         i = 1
-      LOG('getSubObjectDepth',0,'xml2.nodeName: %s' % xml.nodeName)
+      #LOG('getSubObjectDepth',0,'xml2.nodeName: %s' % xml.nodeName)
       for subnode in self.getAttributeNodeList(xml):
-        LOG('getSubObjectDepth',0,'subnode.nodeName: %s' % subnode.nodeName)
+        #LOG('getSubObjectDepth',0,'subnode.nodeName: %s' % subnode.nodeName)
         if subnode.nodeName == 'select':
           value = subnode.nodeValue
-          LOG('getSubObjectDepth',0,'subnode.nodeValue: %s' % subnode.nodeValue)
+          #LOG('getSubObjectDepth',0,'subnode.nodeValue: %s' % subnode.nodeValue)
           if re.search(self.sub_sub_object_exp,value) is not None:
             return 2 # This is sure in all cases
           elif re.search(self.sub_object_exp,value) is not None:
@@ -700,11 +700,11 @@
     if xml is None:
       return
     if type(xml) in (type('a'),type(u'a')):
-      LOG('Conduit.convertToXml xml',0,repr(xml))
+      #LOG('Conduit.convertToXml xml',0,repr(xml))
       if type(xml) is type(u'a'):
         xml = xml.encode('utf-8')
       xml = Parse(xml)
-      LOG('Conduit.convertToXml not failed',0,'ok')
+      #LOG('Conduit.convertToXml not failed',0,'ok')
       xml = xml.childNodes[0] # Because we just created a new xml
     # If we have the xml from the node erp5, we just take the subnode
     if xml.nodeName=='erp5':
@@ -824,7 +824,7 @@
     for subnode in self.getElementNodeList(xml):
       if subnode.nodeName in self.XUPDATE_EL:
         e_list += [subnode]
-    LOG('getXupdateElementList, e_list:',0,e_list)
+    #LOG('getXupdateElementList, e_list:',0,e_list)
     return e_list
 
   security.declareProtected(Permissions.AccessContentsInformation,'getElementFromXupdate')
@@ -879,7 +879,7 @@
       maxi = xml_string.find('>')+1
       result += xml_string[maxi:xml_string.find('</%s>' % xml.nodeName)]
       result += '</' + property + '>'
-      LOG('getElementFromXupdate, result:',0,repr(result))
+      #LOG('getElementFromXupdate, result:',0,repr(result))
       return self.convertToXml(result)
     return xml
 
@@ -1037,7 +1037,7 @@
     own Conduit.
     """
     portal_types = getToolByName(object,'portal_types')
-    LOG('ERP5Conduit.addNode',0,'portal_type: |%s|' % str(portal_type))
+    #LOG('ERP5Conduit.addNode',0,'portal_type: |%s|' % str(portal_type))
     if docid==None: # ERP5 content
       object.newContent(portal_type=portal_type,id=object_id)
     else: # CPS content
@@ -1065,27 +1065,27 @@
     This is really usefull if you want to write your own Conduit.
     """
     conflict_list = []
-    LOG('addNode, workflow_history isHistoryAdd:',0,self.isHistoryAdd(xml))
+    #LOG('addNode, workflow_history isHistoryAdd:',0,self.isHistoryAdd(xml))
     # We want to add a workflow action
     wf_tool = getToolByName(object,'portal_workflow')
     wf_id = self.getAttribute(xml,'id')
     if wf_id is None: # History added by xupdate
       wf_id = self.getHistoryIdFromSelect(xml)
-      LOG('addNode, workflow_history id:',0,wf_id)
+      #LOG('addNode, workflow_history id:',0,wf_id)
       #LOG('addNode, workflow_history xml:',0,xml.toxml())#toxml isn't in 4Suite
-      LOG('addNode, workflow_history xml.getElmentNodeList:',0,self.getElementNodeList(xml))
+      #LOG('addNode, workflow_history xml.getElmentNodeList:',0,self.getElementNodeList(xml))
       xml = self.getElementNodeList(xml)[0]
-    LOG('addNode, workflow_history id:',0,wf_id)
-    LOG('addNode, workflow_history xml:',0,xml)
+    #LOG('addNode, workflow_history id:',0,wf_id)
+    #LOG('addNode, workflow_history xml:',0,xml)
     #for action in self.getWorkflowActionFromXml(xml):
     status = self.getStatusFromXml(xml)
-    LOG('addNode, status:',0,status)
+    #LOG('addNode, status:',0,status)
     add_action = self.isWorkflowActionAddable(object=object,
                                            status=status,wf_tool=wf_tool,
                                            wf_id=wf_id,xml=xml)
-    LOG('addNode, workflow_history add_action:',0,add_action)
+    #LOG('addNode, workflow_history add_action:',0,add_action)
     if add_action and not simulate:
-      LOG('addNode, setting status:',0,'ok')
+      #LOG('addNode, setting status:',0,'ok')
       wf_tool.setStatusOf(wf_id,object,status)
 
     # Specific CPS, try to remove duplicate lines in portal_repository._histories




More information about the Erp5-report mailing list