From 2301122d9510a4dbdc48bc22bceed6e8419657ee Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Thu, 31 Jan 2008 14:32:10 +0000
Subject: [PATCH] Get object\'s attributes without Acquisition, use getattr
 instead hasattr

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18946 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ZLDAPConnection/LDCAccessors.py |  3 ++-
 product/ZLDAPConnection/ZLDAP.py        | 11 ++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/product/ZLDAPConnection/LDCAccessors.py b/product/ZLDAPConnection/LDCAccessors.py
index e44496819d..b54795f5d1 100644
--- a/product/ZLDAPConnection/LDCAccessors.py
+++ b/product/ZLDAPConnection/LDCAccessors.py
@@ -1,6 +1,7 @@
 
 __version__="$Revision: 1.3 $"[11:-2]
 
+from Acquisition import aq_base
 class LDAPConnectionAccessors:
     """ getters / setters for LDAP Properties """
 
@@ -67,7 +68,7 @@ class LDAPConnectionAccessors:
         """ self.openc means that the connection is open to Zope.  However,
         the connection to the LDAP server may or may not be opened.  If
         this returns false, we shouldn't even try connecting."""
-        return self.openc
+        return getattr(aq_base(self), 'openc', None)
 
     def setOpenConnection(self, openc):
         self._v_openc = openc
diff --git a/product/ZLDAPConnection/ZLDAP.py b/product/ZLDAPConnection/ZLDAP.py
index dfb453325d..32fdd92dbf 100644
--- a/product/ZLDAPConnection/ZLDAP.py
+++ b/product/ZLDAPConnection/ZLDAP.py
@@ -10,6 +10,7 @@
 __version__ = "$Revision: 1.11 $"[11:-2]
 
 import Acquisition, AccessControl, OFS, string
+from Acquisition import aq_base
 from Globals import HTMLFile, MessageDialog, Persistent
 import ldap, urllib
 
@@ -108,12 +109,12 @@ class ZLDAPConnection(
     def _EntryFactory(self):
         """ Stamps out an Entry class to be used for every entry returned,
         taking into account transactional versus non-transactional """
-        return getattr(self, '_v_entryclass', self._refreshEntryClass())
+        return getattr(aq_base(self), '_v_entryclass', self._refreshEntryClass())
 
     ### Tree stuff
     def __bobo_traverse__(self, REQUEST, key):
         key=urllib.unquote(key)
-        if hasattr(self, key):
+        if getattr(self, key, None) is not None:
             return getattr(self, key)
         return self.getRoot()[key]
 
@@ -146,7 +147,7 @@ class ZLDAPConnection(
         elif o._isNew or o._isDeleted:
             oko.append(o)
         self._v_okobjects=oko
-        
+
     def tpc_finish(self, *ignored):
         " really really commit and DON'T FAIL "
         oko=self._v_okobjects
@@ -367,7 +368,7 @@ class ZLDAPConnection(
 
     def isOpen(self):
         " quickly checks to see if the connection's open "
-        if not hasattr(self, '_v_conn'):
+        if getattr(aq_base(self), '_v_conn', None) is None:
             self._v_conn = None
         if self._v_conn is None or not self.shouldBeOpen():
             return 0
@@ -413,7 +414,7 @@ class ZLDAPConnection(
 
     def _close(self):
         """ close a connection """
-        if self.getOpenConnection() == 0:
+        if self.getOpenConnection() is None:
             #I'm already closed, but someone is still trying to close me
             self._v_conn = None
             self._v_openc = 0
-- 
2.30.9