register LDAP router
[matthijs/upstream/django-ldapdb.git] / ldapdb / __init__.py
index 7dde301da3532915ec9e0a099a8b881026038f6c..cfa1dd3bfa7af423d0271df12db3a78c0867810a 100644 (file)
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
+from django import db
 from django.conf import settings
-from django.db import connections
+
+from ldapdb.router import Router
 
 def escape_ldap_filter(value):
     value = unicode(value)
@@ -43,11 +45,13 @@ def escape_ldap_filter(value):
                 .replace(')', '\\29') \
                 .replace('\0', '\\00')
 
-# Add the LDAP backend to the configured databases
+# 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 = connections['ldap']
+connection = db.connections['ldap']
 
+# Add the LDAP router
+db.router.routers.append(Router())