Added principal attributes
authorThierry Florac <tflorac@ulthar.net>
Sat, 28 Feb 2015 15:28:02 +0100
changeset 10 c9cf6a49501f
parent 9 22f742b01ece
child 11 7f3ca73c67e6
Added principal attributes
src/pyams_security/principal.py
--- a/src/pyams_security/principal.py	Sat Feb 28 15:26:58 2015 +0100
+++ b/src/pyams_security/principal.py	Sat Feb 28 15:28:02 2015 +0100
@@ -31,11 +31,12 @@
 
     id = FieldProperty(IPrincipalInfo['id'])
     title = FieldProperty(IPrincipalInfo['title'])
-    groups = FieldProperty(IPrincipalInfo['groups'])
+    attributes = FieldProperty(IPrincipalInfo['attributes'])
 
     def __init__(self, **kwargs):
-        self.id = kwargs.get('id')
-        self.title = kwargs.get('title')
+        self.id = kwargs.pop('id')
+        self.title = kwargs.pop('title', '__unknown__')
+        self.attributes = kwargs
 
     def __eq__(self, other):
         return isinstance(other, PrincipalInfo) and (self.id == other.id)
@@ -69,7 +70,7 @@
 
     @property
     def title(self):
-        return 'MissingPrincipal: {0}'.format(self.id)
+        return 'MissingPrincipal: {id}'.format(id=self.id)
 
     def __eq__(self, other):
         return isinstance(other, PrincipalInfo) and (self.id == other.id)