summaryrefslogtreecommitdiff
path: root/pynslcd/common.py
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2012-01-29 14:39:25 +0000
committerArthur de Jong <arthur@arthurdejong.org>2012-01-29 14:39:25 +0000
commitfcce277a6e8d56036f6a33bda67aa8dcc03be142 (patch)
tree0c8244da8d000d8a0029f76618e98a48a5bb976f /pynslcd/common.py
parent0a8ff1c61c193b17b04adb0c3ced239846be855d (diff)
split the result handling into a convert() and write() step
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1613 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd/common.py')
-rw-r--r--pynslcd/common.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/pynslcd/common.py b/pynslcd/common.py
index 375afed..7f41a11 100644
--- a/pynslcd/common.py
+++ b/pynslcd/common.py
@@ -101,14 +101,13 @@ class Search(object):
self.attributes = attributes or self.attmap.attributes()
def __iter__(self):
- return self()
+ return self.items()
- def __call__(self):
- # get search results
+ def items(self):
+ """Return the results from the search."""
filter = self.mk_filter()
for base in self.bases:
logging.debug('SEARCHING %s', base)
- # do the LDAP search
try:
for entry in self.conn.search_s(base, self.scope, filter, self.attributes):
if entry[0]:
@@ -198,13 +197,15 @@ class Request(object):
"""This method handles the request based on the parameters read
with read_parameters()."""
for dn, attributes in self.search(conn=self.conn, parameters=parameters):
- self.write(dn, attributes, parameters)
+ for values in self.convert(dn, attributes, parameters):
+ self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)
+ self.write(*values)
# write the final result code
self.fp.write_int32(constants.NSLCD_RESULT_END)
def __call__(self):
parameters = self.read_parameters(self.fp) or {}
- # TODO: log call with parameters
+ logging.debug('%s(%r)', self.__class__.__name__, parameters)
self.fp.write_int32(constants.NSLCD_VERSION)
self.fp.write_int32(self.action)
self.handle_request(parameters)