stop using custom "Query" object
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 11 Apr 2011 12:30:42 +0000 (12:30 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 11 Apr 2011 12:30:42 +0000 (12:30 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@1035 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/query.py

index 8fe595f89da4b08d83a0517462349c1b662412d4..6b1c2233425738d489f8bb6a12b71753ff24bc2b 100644 (file)
@@ -38,7 +38,7 @@ import ldap
 from django.db import connections
 from django.db.models.query import QuerySet as BaseQuerySet
 from django.db.models.query_utils import Q
-from django.db.models.sql import Query as BaseQuery
+from django.db.models.sql import Query
 from django.db.models.sql.where import WhereNode as BaseWhereNode, Constraint as BaseConstraint, AND, OR
 
 from ldapdb.backends.ldap import compiler
@@ -87,31 +87,6 @@ class WhereNode(BaseWhereNode):
             obj = Constraint(obj.alias, obj.col, obj.field)
         super(WhereNode, self).add((obj, lookup_type, value), connector)
 
-class Query(BaseQuery):
-    def get_count(self, using):
-        connection = connections[using]
-        try:
-            vals = connection.search_s(
-                self.model.base_dn,
-                self.model.search_scope,
-                filterstr=compiler.query_as_ldap(self),
-                attrlist=[],
-            )
-        except ldap.NO_SUCH_OBJECT:
-            return 0
-
-        number = len(vals)
-
-        # apply limit and offset
-        number = max(0, number - self.low_mark)
-        if self.high_mark is not None:
-            number = min(number, self.high_mark - self.low_mark)
-
-        return number
-
-    def has_results(self, using):
-        return self.get_count(using) != 0
-
 class QuerySet(BaseQuerySet):
     def __init__(self, model=None, query=None, using=None):
         if not query: