src/pyams_content/component/paragraph/verbatim.py
changeset 555 8e8a14452567
parent 450 9a6afbc6ab4f
child 586 28445044f6e3
--- a/src/pyams_content/component/paragraph/verbatim.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/verbatim.py	Fri May 25 08:03:41 2018 +0200
@@ -25,15 +25,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 _
 
@@ -43,7 +42,8 @@
 #
 
 @implementer(IVerbatimParagraph, IIllustrationTarget)
-class VerbatimParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IVerbatimParagraph)
+class VerbatimParagraph(BaseParagraph):
     """Verbatim paragraph"""
 
     icon_class = 'fa-quote-right'
@@ -96,16 +96,7 @@
 
 
 @vocabulary_config(name=VERBATIM_PARAGRAPH_RENDERERS)
-class VerbatimParagraphRendererVocabulary(SimpleVocabulary):
+class VerbatimParagraphRendererVocabulary(RenderersVocabulary):
     """Verbatim paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IVerbatimParagraph.providedBy(context):
-            context = VerbatimParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(VerbatimParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IVerbatimParagraph