only use legacy db parameters if available
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 11 Apr 2011 14:04:59 +0000 (14:04 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 11 Apr 2011 14:04:59 +0000 (14:04 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@1042 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/__init__.py

index 521188cea9a0abe183e1b4bb7e547985c86ea701..4d6f8cf8a8a98eb20d4ab3e9cb910b13e68e54ff 100644 (file)
@@ -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())