From 559b871844937ebede2caccd8d1c1e0840405e75 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Thu, 9 Oct 2008 08:15:52 +0000
Subject: [PATCH] Avoid looping on all attriubutes

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24114 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5SyncML/Conduit/ERP5Conduit.py | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/product/ERP5SyncML/Conduit/ERP5Conduit.py b/product/ERP5SyncML/Conduit/ERP5Conduit.py
index 08d7af12d1..0df7b45c16 100644
--- a/product/ERP5SyncML/Conduit/ERP5Conduit.py
+++ b/product/ERP5SyncML/Conduit/ERP5Conduit.py
@@ -695,11 +695,9 @@ class ERP5Conduit(XMLSyncUtilsMixin):
     Retrieve the portal type from an xml
     """
     portal_type = None
-    for subnode in self.getAttributeNodeList(xml):
-      if subnode.nodeName == 'portal_type':
-        portal_type = subnode.nodeValue
-        portal_type = self.convertXmlValue(portal_type)
-        return portal_type
+    attr_list = xml.xpath('.//@portal_type[1]')
+    if attr_list:
+      portal_type = attr_list[0].value.encode('utf-8')
     return portal_type
 
   security.declareProtected(Permissions.AccessContentsInformation,'getPropertyType')
@@ -707,12 +705,11 @@ class ERP5Conduit(XMLSyncUtilsMixin):
     """
     Retrieve the portal type from an xml
     """
-    p_type = None # use getElementsByTagName !!!! XXX
-    for subnode in self.getAttributeNodeList(xml):
-      if subnode.nodeName == 'type':
-        p_type = subnode.nodeValue
-        p_type = self.convertXmlValue(p_type,data_type='string')
-        return p_type
+    p_type = None
+    attr_list = xml.xpath('.//@type[1]')
+    if attr_list:
+      p_type = attr_list[0].value.encode('utf-8')
+      p_type = self.convertXmlValue(p_type, data_type='string')
     return p_type
 
   security.declareProtected(Permissions.AccessContentsInformation,'getXupdateObjectType')
-- 
2.30.9