src/pyams_content/component/paragraph/keypoint.py
changeset 555 8e8a14452567
parent 421 20a2b671ade1
child 586 28445044f6e3
--- a/src/pyams_content/component/paragraph/keypoint.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/keypoint.py	Fri May 25 08:03:41 2018 +0200
@@ -20,27 +20,26 @@
 from pyams_content.component.paragraph.interfaces.keypoint import IKeypointsParagraph, KEYPOINTS_PARAGRAPH_TYPE, \
     KEYPOINTS_PARAGRAPH_RENDERERS
 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
-from pyams_content.features.renderer.interfaces import IContentRenderer
 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
 
 # import packages
 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
-from pyams_content.features.renderer import RenderedContentMixin
+from pyams_content.features.renderer import RenderersVocabulary
 from pyams_utils.adapter import adapter_config
+from pyams_utils.factory import factory_config
 from pyams_utils.registry import utility_config, get_utility
-from pyams_utils.request import check_request
 from pyams_utils.text import get_text_start
 from pyams_utils.traversing import get_parent
 from pyams_utils.vocabulary import vocabulary_config
 from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_content import _
 
 
 @implementer(IKeypointsParagraph)
-class KeypointsParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IKeypointsParagraph)
+class KeypointsParagraph(BaseParagraph):
     """Key points paragraph"""
 
     icon_class = 'fa-key'
@@ -90,16 +89,7 @@
 
 
 @vocabulary_config(name=KEYPOINTS_PARAGRAPH_RENDERERS)
-class KeypointsParagraphRendererVocabulary(SimpleVocabulary):
+class KeypointsParagraphRendererVocabulary(RenderersVocabulary):
     """Key points paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IKeypointsParagraph.providedBy(context):
-            context = KeypointsParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(KeypointsParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IKeypointsParagraph