--- a/src/pyams_security/principal.py Wed May 20 12:31:27 2015 +0200
+++ b/src/pyams_security/principal.py Wed Jun 17 09:59:18 2015 +0200
@@ -17,8 +17,12 @@
# import interfaces
from pyams_security.interfaces import IPrincipalInfo
+from zope.annotation.interfaces import IAnnotations
+from zope.principalannotation.interfaces import IPrincipalAnnotationUtility
# import packages
+from pyams_utils.adapter import adapter_config
+from pyams_utils.registry import query_utility
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
@@ -74,3 +78,11 @@
def __eq__(self, other):
return isinstance(other, PrincipalInfo) and (self.id == other.id)
+
+
+@adapter_config(context=IPrincipalInfo, provides=IAnnotations)
+def get_principal_annotations(principal):
+ """Principal annotations adapter"""
+ annotations = query_utility(IPrincipalAnnotationUtility)
+ if annotations is not None:
+ return annotations.getAnnotations(principal)