From fcce277a6e8d56036f6a33bda67aa8dcc03be142 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sun, 29 Jan 2012 14:39:25 +0000 Subject: 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 --- pynslcd/service.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'pynslcd/service.py') diff --git a/pynslcd/service.py b/pynslcd/service.py index 6923236..c89ac6f 100644 --- a/pynslcd/service.py +++ b/pynslcd/service.py @@ -1,7 +1,7 @@ # service.py - service entry lookup routines # -# Copyright (C) 2011 Arthur de Jong +# Copyright (C) 2011, 2012 Arthur de Jong # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,11 +18,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA -import logging import ldap.filter +import logging -import constants import common +import constants attmap = common.Attributes(cn='cn', @@ -41,19 +41,18 @@ class Search(common.Search): class ServiceRequest(common.Request): - def write(self, dn, attributes, parameters): - # get values + def write(self, name, aliases, port, protocol): + self.fp.write_string(name) + self.fp.write_stringlist(aliases) + self.fp.write_int32(port) + self.fp.write_string(protocol) + + def convert(self, dn, attributes, parameters): names = attributes['cn'] - name = names.pop(0) port = int(attributes['ipServicePort'][0]) protocols = attributes['ipServiceProtocol'] - # write result for protocol in protocols: - self.fp.write_int32(constants.NSLCD_RESULT_BEGIN) - self.fp.write_string(name) - self.fp.write_stringlist(names) - self.fp.write_int32(port) - self.fp.write_string(protocol) + yield (names[0], names[1:], port, protocol) class ServiceByNameRequest(ServiceRequest): -- cgit v1.2.3