Updated IPrincipalMailInfo adapters
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 13:40:15 +0200
changeset 23 acd4a4eef95d
parent 22 216ba0fca6c5
child 24 8547bf49b3db
Updated IPrincipalMailInfo adapters
src/pyams_ldap/plugin.py
--- a/src/pyams_ldap/plugin.py	Tue Jun 06 18:12:11 2017 +0200
+++ b/src/pyams_ldap/plugin.py	Mon Sep 11 13:40:15 2017 +0200
@@ -103,7 +103,8 @@
 
         mail = user.attributes.get(plugin.mail_attribute)
         if mail:
-            return {(plugin.title_format.format(**user.attributes), mail[0])}
+            return {(plugin.title_format.format(**user.attributes),
+                     mail[0] if isinstance(mail, (list, tuple)) else mail)}
         else:
             return set()
 
@@ -143,7 +144,8 @@
             # use group internal attribute
             mail = group.attributes.get(plugin.group_mail_attribute)
             if mail:
-                yield plugin.group_title_format(**group.attributes), mail[0]
+                yield plugin.group_title_format(**group.attributes), \
+                      mail[0] if isinstance(mail, (list, tuple)) else mail
 
         else:
             # redirect: use internal attribute of another group
@@ -158,7 +160,8 @@
             target_dn, attrs = result[0]
             mail = attrs.get(plugin.group_mail_attribute)
             if mail:
-                yield plugin.group_title_format(**attrs), mail[0]
+                yield plugin.group_title_format(**attrs), \
+                      mail[0] if isinstance(mail, (list, tuple)) else mail
 
 
 @implementer(ILDAPPlugin)