From 5bf1be6a3bcee78f60c056821f828ba1d0943aa3 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Wed, 31 Oct 2007 17:25:42 +0000
Subject: [PATCH] Use getattr instead of hasattr.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17327 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/XMLMatrix.py | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/product/ERP5Type/XMLMatrix.py b/product/ERP5Type/XMLMatrix.py
index adb2a7b59b..45c4d818f7 100644
--- a/product/ERP5Type/XMLMatrix.py
+++ b/product/ERP5Type/XMLMatrix.py
@@ -68,7 +68,7 @@ class XMLMatrix(Folder):
           Access a cell at row and column
       """
       base_id= kwd.get('base_id', "cell")
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return None
 
       if not self.index.has_key(base_id):
@@ -105,7 +105,7 @@ class XMLMatrix(Folder):
           Checks if matrix corresponding to base_id contains cell specified
           by *kw coordinates.
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return 0
 
       base_id= kwd.get('base_id', "cell")
@@ -134,7 +134,7 @@ class XMLMatrix(Folder):
       """
       aq_self = aq_base(self)
 
-      if not hasattr(aq_self, 'index'):
+      if getattr(aq_self, 'index', None) is None:
         return 0
 
       if not self.index.has_key(base_id):
@@ -153,7 +153,7 @@ class XMLMatrix(Folder):
           Checks if *kw coordinates are in the range of the
         matrix in kwd['base_id'].
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return 0
 
       base_id = kwd.get('base_id', "cell")
@@ -183,7 +183,7 @@ class XMLMatrix(Folder):
                                       # between keys and ids of cells
 
       base_id= kwd.get('base_id', "cell")
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         self.index = PersistentMapping()
 
       # Return if previous range is the same
@@ -473,7 +473,7 @@ class XMLMatrix(Folder):
       """
           Returns the cell range as a list of index ids
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return []
       cell_range = self.index.get(base_id, None)
       if cell_range is None: return None
@@ -490,7 +490,7 @@ class XMLMatrix(Folder):
       """
           This method creates a new cell
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return None
       base_id= kwd.get('base_id', "cell")
       cell_id = base_id
@@ -534,7 +534,7 @@ class XMLMatrix(Folder):
       """
         Returns a list of possible keys as tuples
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return ()
       if not self.index.has_key(base_id):
         return ()
@@ -578,7 +578,7 @@ class XMLMatrix(Folder):
       """
         Returns a list of possible ids as tuples
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return ()
       if not self.index.has_key(base_id):
         return ()
@@ -626,7 +626,7 @@ class XMLMatrix(Folder):
       """
         Return possible base_id values
       """
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         return ()
       return self.index.keys()
 
@@ -660,7 +660,7 @@ class XMLMatrix(Folder):
       to_delete = []
       errors = []
       # We make sure first that there is an index
-      if not hasattr(aq_base(self), 'index'):
+      if getattr(aq_base(self), 'index', None) is None:
         self.index = PersistentMapping()
       # We will check each cell of the matrix the matrix
       for obj in self.objectValues():
-- 
2.30.9