src/pyams_content/features/review/__init__.py
changeset 558 d9c6b1d7fefa
parent 501 3407e6940f6a
child 604 581b1be90ee7
--- a/src/pyams_content/features/review/__init__.py	Fri May 25 08:05:13 2018 +0200
+++ b/src/pyams_content/features/review/__init__.py	Fri May 25 15:48:59 2018 +0200
@@ -29,7 +29,6 @@
 from pyams_security.interfaces.notification import INotificationSettings
 from pyramid_chameleon.interfaces import IChameleonTranslate
 from pyramid_mailer.interfaces import IMailer
-from zope.annotation.interfaces import IAnnotations
 from zope.location.interfaces import ISublocations
 from zope.traversing.interfaces import ITraversable
 
@@ -37,7 +36,7 @@
 from persistent import Persistent
 from pyams_mail.message import HTMLMessage
 from pyams_security.principal import MissingPrincipal
-from pyams_utils.adapter import adapter_config, ContextAdapter
+from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
 from pyams_utils.container import BTreeOrderedContainer
 from pyams_utils.registry import query_utility, get_utility
 from pyams_utils.request import check_request, query_request
@@ -47,7 +46,6 @@
 from pyramid_chameleon.zpt import PageTemplateFile
 from zope.container.contained import Contained
 from zope.interface import implementer
-from zope.location import locate
 from zope.schema.fieldproperty import FieldProperty
 
 from pyams_content import _
@@ -97,12 +95,8 @@
 @adapter_config(context=IReviewTarget, provides=IReviewComments)
 def shared_content_review_comments_factory(context):
     """Shared content review comments factory"""
-    annotations = IAnnotations(context)
-    comments = annotations.get(REVIEW_COMMENTS_ANNOTATION_KEY)
-    if comments is None:
-        comments = annotations[REVIEW_COMMENTS_ANNOTATION_KEY] = ReviewCommentsContainer()
-        locate(comments, context, '++review-comments++')
-    return comments
+    return get_annotation_adapter(context, REVIEW_COMMENTS_ANNOTATION_KEY, ReviewCommentsContainer,
+                                  name='++review-comments++')
 
 
 @adapter_config(name='review-comments', context=IReviewTarget, provides=ITraversable)