make it possible to change the search scope
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Sun, 10 Oct 2010 18:39:48 +0000 (18:39 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Sun, 10 Oct 2010 18:39:48 +0000 (18:39 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@953 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/base.py
ldapdb/models/query.py

index f0ed746..d09a5e0 100644 (file)
@@ -68,6 +68,7 @@ class Model(django.db.models.base.Model):
 
     # meta-data
     base_dn = None
+    search_scope = ldap.SCOPE_SUBTREE
     object_classes = ['top']
 
     def __init__(self, *args, **kwargs):
index f90c9b1..0b5e8ba 100644 (file)
@@ -94,7 +94,7 @@ class Compiler(object):
         try:
             vals = self.connection.search_s(
                 self.query.model.base_dn,
-                ldap.SCOPE_SUBTREE,
+                self.query.model.search_scope,
                 filterstr=self.query._ldap_filter(),
                 attrlist=attrlist,
             )
@@ -219,7 +219,7 @@ class Query(BaseQuery):
         try:
             vals = ldapdb.connection.search_s(
                 self.model.base_dn,
-                ldap.SCOPE_SUBTREE,
+                self.model.search_scope,
                 filterstr=self._ldap_filter(),
                 attrlist=[],
             )
@@ -260,7 +260,7 @@ class QuerySet(BaseQuerySet):
         try:
             vals = ldapdb.connection.search_s(
                 self.model.base_dn,
-                ldap.SCOPE_SUBTREE,
+                self.model.search_scope,
                 filterstr=self.query._ldap_filter(),
                 attrlist=[],
             )