From eaafba42e8cb7e21e68ab0a4be0a76d326818b91 Mon Sep 17 00:00:00 2001 From: jlaine Date: Mon, 11 Apr 2011 08:21:41 +0000 Subject: [PATCH] add missing code git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@1017 e071eeec-0327-468d-9b6a-08194a12b294 --- ldapdb/backends/ldap/compiler.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ldapdb/backends/ldap/compiler.py b/ldapdb/backends/ldap/compiler.py index ab17bd4..a3cde18 100644 --- a/ldapdb/backends/ldap/compiler.py +++ b/ldapdb/backends/ldap/compiler.py @@ -32,6 +32,8 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +import ldap + class SQLCompiler(object): def __init__(self, query, connection, using): self.query = query @@ -82,3 +84,26 @@ class SQLCompiler(object): if val: return val return 0 + vals = sorted(vals, cmp=cmpvals) + + # process results + pos = 0 + for dn, attrs in vals: + # FIXME : This is not optimal, we retrieve more results than we need + # but there is probably no other options as we can't perform ordering + # server side. + if (self.query.low_mark and pos < self.query.low_mark) or \ + (self.query.high_mark is not None and pos >= self.query.high_mark): + pos += 1 + continue + row = [] + for field in iter(fields): + if field.attname == 'dn': + row.append(dn) + elif hasattr(field, 'from_ldap'): + row.append(field.from_ldap(attrs.get(field.db_column, []), connection=self.connection)) + else: + row.append(None) + yield row + pos += 1 + -- 2.30.2