src/pyams_security/principal.py
changeset 10 c9cf6a49501f
parent 2 94e76f8e9828
child 42 07229ac2497b
equal deleted inserted replaced
9:22f742b01ece 10:c9cf6a49501f
    29 class PrincipalInfo(object):
    29 class PrincipalInfo(object):
    30     """Generic principal info"""
    30     """Generic principal info"""
    31 
    31 
    32     id = FieldProperty(IPrincipalInfo['id'])
    32     id = FieldProperty(IPrincipalInfo['id'])
    33     title = FieldProperty(IPrincipalInfo['title'])
    33     title = FieldProperty(IPrincipalInfo['title'])
    34     groups = FieldProperty(IPrincipalInfo['groups'])
    34     attributes = FieldProperty(IPrincipalInfo['attributes'])
    35 
    35 
    36     def __init__(self, **kwargs):
    36     def __init__(self, **kwargs):
    37         self.id = kwargs.get('id')
    37         self.id = kwargs.pop('id')
    38         self.title = kwargs.get('title')
    38         self.title = kwargs.pop('title', '__unknown__')
       
    39         self.attributes = kwargs
    39 
    40 
    40     def __eq__(self, other):
    41     def __eq__(self, other):
    41         return isinstance(other, PrincipalInfo) and (self.id == other.id)
    42         return isinstance(other, PrincipalInfo) and (self.id == other.id)
    42 
    43 
    43     def __hash__(self):
    44     def __hash__(self):
    67     def __init__(self, **kwargs):
    68     def __init__(self, **kwargs):
    68         self.id = kwargs.get('id')
    69         self.id = kwargs.get('id')
    69 
    70 
    70     @property
    71     @property
    71     def title(self):
    72     def title(self):
    72         return 'MissingPrincipal: {0}'.format(self.id)
    73         return 'MissingPrincipal: {id}'.format(id=self.id)
    73 
    74 
    74     def __eq__(self, other):
    75     def __eq__(self, other):
    75         return isinstance(other, PrincipalInfo) and (self.id == other.id)
    76         return isinstance(other, PrincipalInfo) and (self.id == other.id)