move transaction disable
[matthijs/upstream/django-ldapdb.git] / ldapdb / __init__.py
index cfa1dd3bfa7af423d0271df12db3a78c0867810a..dde6304e1b5d0cf8331f60ecb7d0164c3a25ff6c 100644 (file)
@@ -45,13 +45,15 @@ 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}
-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}
+    connection = db.connections['ldap']
 
-# Add the LDAP router
-db.router.routers.append(Router())
+    # Add the LDAP router
+    db.router.routers.append(Router())