src/pyams_content/component/paragraph/frame.py
changeset 555 8e8a14452567
parent 447 3665317b6009
child 586 28445044f6e3
--- a/src/pyams_content/component/paragraph/frame.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/frame.py	Fri May 25 08:03:41 2018 +0200
@@ -27,15 +27,14 @@
 
 # import packages
 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
-from pyams_content.features.renderer import RenderedContentMixin, IContentRenderer
+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.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 _
 
@@ -45,7 +44,8 @@
 #
 
 @implementer(IFrameParagraph, IIllustrationTarget, IExtFileContainerTarget, ILinkContainerTarget)
-class FrameParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IFrameParagraph)
+class FrameParagraph(BaseParagraph):
     """Framed text paragraph"""
 
     icon_class = 'fa-list-alt'
@@ -91,16 +91,7 @@
 
 
 @vocabulary_config(name=FRAME_PARAGRAPH_RENDERERS)
-class FrameParagraphRendererVocabulary(SimpleVocabulary):
+class FrameParagraphRendererVocabulary(RenderersVocabulary):
     """Framed text paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IFrameParagraph.providedBy(context):
-            context = FrameParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(FrameParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IFrameParagraph