equal
deleted
inserted
replaced
15 |
15 |
16 # import standard library |
16 # import standard library |
17 |
17 |
18 # import interfaces |
18 # import interfaces |
19 from pyams_security.interfaces import IPrincipalInfo |
19 from pyams_security.interfaces import IPrincipalInfo |
|
20 from zope.annotation.interfaces import IAnnotations |
|
21 from zope.principalannotation.interfaces import IPrincipalAnnotationUtility |
20 |
22 |
21 # import packages |
23 # import packages |
|
24 from pyams_utils.adapter import adapter_config |
|
25 from pyams_utils.registry import query_utility |
22 from zope.interface import implementer |
26 from zope.interface import implementer |
23 from zope.schema.fieldproperty import FieldProperty |
27 from zope.schema.fieldproperty import FieldProperty |
24 |
28 |
25 from pyams_security import _ |
29 from pyams_security import _ |
26 |
30 |
72 def title(self): |
76 def title(self): |
73 return 'MissingPrincipal: {id}'.format(id=self.id) |
77 return 'MissingPrincipal: {id}'.format(id=self.id) |
74 |
78 |
75 def __eq__(self, other): |
79 def __eq__(self, other): |
76 return isinstance(other, PrincipalInfo) and (self.id == other.id) |
80 return isinstance(other, PrincipalInfo) and (self.id == other.id) |
|
81 |
|
82 |
|
83 @adapter_config(context=IPrincipalInfo, provides=IAnnotations) |
|
84 def get_principal_annotations(principal): |
|
85 """Principal annotations adapter""" |
|
86 annotations = query_utility(IPrincipalAnnotationUtility) |
|
87 if annotations is not None: |
|
88 return annotations.getAnnotations(principal) |