From d66162ad308878d2f3fb505a05742798283a8854 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Mon, 12 Aug 2013 22:42:56 +0200 Subject: Use retrieve_by, group_by and group_columns in the cache This removes custom retrieve() functions and Query classes from the database modules and uses retrieve_sql retrieve_by, group_by and group_columns to make a custom retrieval query. In the cache module this completely replaces how the query grouping is done. The Query class is now only used inside the cache and the CnAliasedQuery, RowGrouper and related classed have been removed. --- pynslcd/alias.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'pynslcd/alias.py') diff --git a/pynslcd/alias.py b/pynslcd/alias.py index d5ae390..371ac2e 100644 --- a/pynslcd/alias.py +++ b/pynslcd/alias.py @@ -60,11 +60,17 @@ class Cache(cache.Cache): ON `alias_member_cache`.`alias` = `alias_cache`.`cn` ''' - def retrieve(self, parameters): - query = cache.Query(self.retrieve_sql, parameters) - # return results, returning the members as a list - for row in cache.RowGrouper(query.execute(self.con), ('cn', ), ('rfc822MailMember', )): - yield row['cn'], row['rfc822MailMember'] + retrieve_by = dict( + rfc822MailMember=''' + `cn` IN ( + SELECT `a`.`alias` + FROM `alias_member_cache` `a` + WHERE `a`.`rfc822MailMember` = ?) + ''', + ) + + group_by = (0, ) # cn + group_columns = (1, ) # rfc822MailMember class AliasRequest(common.Request): -- cgit v1.2.3