Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/pynslcd/service.py
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2012-01-29 15:39:25 +0100
committerArthur de Jong <arthur@arthurdejong.org>2012-01-29 15:39:25 +0100
commitfcce277a6e8d56036f6a33bda67aa8dcc03be142 (patch)
tree0c8244da8d000d8a0029f76618e98a48a5bb976f /pynslcd/service.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/service.py')
-rw-r--r--pynslcd/service.py23
1 files changed, 11 insertions, 12 deletions
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):