From: jlaine Date: Mon, 11 Apr 2011 14:04:59 +0000 (+0000) Subject: only use legacy db parameters if available X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=commitdiff_plain;h=82a5a4df7e7899646501206fb99925c79394d1c6 only use legacy db parameters if available git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@1042 e071eeec-0327-468d-9b6a-08194a12b294 --- diff --git a/ldapdb/__init__.py b/ldapdb/__init__.py index 521188c..4d6f8cf 100644 --- a/ldapdb/__init__.py +++ b/ldapdb/__init__.py @@ -45,14 +45,16 @@ def escape_ldap_filter(value): .replace(')', '\\29') \ .replace('\0', '\\00') -# Add the LDAP backend -settings.DATABASES['ldap'] = { - 'ENGINE': 'ldapdb.backends.ldap', - 'NAME': settings.LDAPDB_SERVER_URI, - 'USER': settings.LDAPDB_BIND_DN, - 'PASSWORD': settings.LDAPDB_BIND_PASSWORD, - 'SUPPORTS_TRANSACTIONS': False} -connection = db.connections['ldap'] +# Legacy single database support +if hasattr(settings, 'LDAPDB_SERVER_URI'): + # Add the LDAP backend + settings.DATABASES['ldap'] = { + 'ENGINE': 'ldapdb.backends.ldap', + 'NAME': settings.LDAPDB_SERVER_URI, + 'USER': settings.LDAPDB_BIND_DN, + 'PASSWORD': settings.LDAPDB_BIND_PASSWORD, + 'SUPPORTS_TRANSACTIONS': False} + connection = db.connections['ldap'] -# Add the LDAP router -db.router.routers.append(Router()) + # Add the LDAP router + db.router.routers.append(Router())