[Erp5-report] r18946 - in /erp5/trunk/products/ZLDAPConnection: LDCAccessors.py ZLDAP.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 31 15:32:10 CET 2008


Author: nicolas
Date: Thu Jan 31 15:32:10 2008
New Revision: 18946

URL: http://svn.erp5.org?rev=18946&view=rev
Log:
Get object\'s attributes without Acquisition, use getattr instead hasattr

Modified:
    erp5/trunk/products/ZLDAPConnection/LDCAccessors.py
    erp5/trunk/products/ZLDAPConnection/ZLDAP.py

Modified: erp5/trunk/products/ZLDAPConnection/LDCAccessors.py
URL: http://svn.erp5.org/erp5/trunk/products/ZLDAPConnection/LDCAccessors.py?rev=18946&r1=18945&r2=18946&view=diff
==============================================================================
--- erp5/trunk/products/ZLDAPConnection/LDCAccessors.py (original)
+++ erp5/trunk/products/ZLDAPConnection/LDCAccessors.py Thu Jan 31 15:32:10 2008
@@ -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 @@
         """ 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

Modified: erp5/trunk/products/ZLDAPConnection/ZLDAP.py
URL: http://svn.erp5.org/erp5/trunk/products/ZLDAPConnection/ZLDAP.py?rev=18946&r1=18945&r2=18946&view=diff
==============================================================================
--- erp5/trunk/products/ZLDAPConnection/ZLDAP.py (original)
+++ erp5/trunk/products/ZLDAPConnection/ZLDAP.py Thu Jan 31 15:32:10 2008
@@ -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 @@
     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 @@
         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 @@
 
     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 @@
 
     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




More information about the Erp5-report mailing list