Commit 2301122d authored by Nicolas Delaby's avatar Nicolas Delaby

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
parent 8efdc1ac
__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
......
......@@ -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]
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment