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] __version__="$Revision: 1.3 $"[11:-2]
from Acquisition import aq_base
class LDAPConnectionAccessors: class LDAPConnectionAccessors:
""" getters / setters for LDAP Properties """ """ getters / setters for LDAP Properties """
...@@ -67,7 +68,7 @@ class LDAPConnectionAccessors: ...@@ -67,7 +68,7 @@ class LDAPConnectionAccessors:
""" self.openc means that the connection is open to Zope. However, """ self.openc means that the connection is open to Zope. However,
the connection to the LDAP server may or may not be opened. If the connection to the LDAP server may or may not be opened. If
this returns false, we shouldn't even try connecting.""" this returns false, we shouldn't even try connecting."""
return self.openc return getattr(aq_base(self), 'openc', None)
def setOpenConnection(self, openc): def setOpenConnection(self, openc):
self._v_openc = openc self._v_openc = openc
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
__version__ = "$Revision: 1.11 $"[11:-2] __version__ = "$Revision: 1.11 $"[11:-2]
import Acquisition, AccessControl, OFS, string import Acquisition, AccessControl, OFS, string
from Acquisition import aq_base
from Globals import HTMLFile, MessageDialog, Persistent from Globals import HTMLFile, MessageDialog, Persistent
import ldap, urllib import ldap, urllib
...@@ -108,12 +109,12 @@ class ZLDAPConnection( ...@@ -108,12 +109,12 @@ class ZLDAPConnection(
def _EntryFactory(self): def _EntryFactory(self):
""" Stamps out an Entry class to be used for every entry returned, """ Stamps out an Entry class to be used for every entry returned,
taking into account transactional versus non-transactional """ 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 ### Tree stuff
def __bobo_traverse__(self, REQUEST, key): def __bobo_traverse__(self, REQUEST, key):
key=urllib.unquote(key) key=urllib.unquote(key)
if hasattr(self, key): if getattr(self, key, None) is not None:
return getattr(self, key) return getattr(self, key)
return self.getRoot()[key] return self.getRoot()[key]
...@@ -367,7 +368,7 @@ class ZLDAPConnection( ...@@ -367,7 +368,7 @@ class ZLDAPConnection(
def isOpen(self): def isOpen(self):
" quickly checks to see if the connection's open " " 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 self._v_conn = None
if self._v_conn is None or not self.shouldBeOpen(): if self._v_conn is None or not self.shouldBeOpen():
return 0 return 0
...@@ -413,7 +414,7 @@ class ZLDAPConnection( ...@@ -413,7 +414,7 @@ class ZLDAPConnection(
def _close(self): def _close(self):
""" close a connection """ """ close a connection """
if self.getOpenConnection() == 0: if self.getOpenConnection() is None:
#I'm already closed, but someone is still trying to close me #I'm already closed, but someone is still trying to close me
self._v_conn = None self._v_conn = None
self._v_openc = 0 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