summaryrefslogtreecommitdiffstats
path: root/ipaserver/plugins/ldap2.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2015-06-22 10:58:43 +0000
committerJan Cholasta <jcholast@redhat.com>2015-07-01 13:05:30 +0000
commite39fe4ed31042bd28357d093fdbd93b4d6d59aaa (patch)
treec9edd3b3d710ae642d91eb8ca0c060cb5f6d0f0c /ipaserver/plugins/ldap2.py
parent2d1515323acb4125306817096bafab6623de0b47 (diff)
downloadfreeipa-e39fe4ed31042bd28357d093fdbd93b4d6d59aaa.tar.gz
freeipa-e39fe4ed31042bd28357d093fdbd93b4d6d59aaa.tar.xz
freeipa-e39fe4ed31042bd28357d093fdbd93b4d6d59aaa.zip
plugable: Pass API to plugins on initialization rather than using set_api
https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipaserver/plugins/ldap2.py')
-rw-r--r--ipaserver/plugins/ldap2.py45
1 files changed, 8 insertions, 37 deletions
diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py
index 36a6fedda..68feee4f0 100644
--- a/ipaserver/plugins/ldap2.py
+++ b/ipaserver/plugins/ldap2.py
@@ -56,47 +56,20 @@ from ipalib.crud import CrudBackend
from ipalib.request import context
-class ldap2(LDAPClient, CrudBackend):
+class ldap2(CrudBackend, LDAPClient):
"""
LDAP Backend Take 2.
"""
- def __init__(self, shared_instance=False, ldap_uri=None, base_dn=None,
- schema=None):
- self.__ldap_uri = None
+ def __init__(self, api, ldap_uri=None):
+ if ldap_uri is None:
+ ldap_uri = api.env.ldap_uri
- CrudBackend.__init__(self, shared_instance=shared_instance)
- LDAPClient.__init__(self, ldap_uri)
+ force_schema_updates = api.env.context in ('installer', 'updates')
- self.__base_dn = base_dn
-
- @property
- def api(self):
- self_api = super(ldap2, self).api
- if self_api is None:
- self_api = api
- return self_api
-
- @property
- def ldap_uri(self):
- try:
- return self.__ldap_uri or self.api.env.ldap_uri
- except AttributeError:
- return 'ldap://example.com'
-
- @ldap_uri.setter
- def ldap_uri(self, value):
- self.__ldap_uri = value
-
- @property
- def base_dn(self):
- try:
- if self.__base_dn is not None:
- return DN(self.__base_dn)
- else:
- return DN(self.api.env.basedn)
- except AttributeError:
- return DN()
+ CrudBackend.__init__(self, api)
+ LDAPClient.__init__(self, ldap_uri,
+ force_schema_updates=force_schema_updates)
def _connect(self):
# Connectible.conn is a proxy to thread-local storage;
@@ -145,8 +118,6 @@ class ldap2(LDAPClient, CrudBackend):
if debug_level:
_ldap.set_option(_ldap.OPT_DEBUG_LEVEL, debug_level)
- object.__setattr__(self, '_force_schema_updates',
- self.api.env.context in ('installer', 'updates'))
LDAPClient._connect(self)
conn = self._conn