src/pyams_content/component/paragraph/header.py
changeset 555 8e8a14452567
parent 538 0bd011d47c0b
child 586 28445044f6e3
--- a/src/pyams_content/component/paragraph/header.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/header.py	Fri May 25 08:03:41 2018 +0200
@@ -20,27 +20,26 @@
 from pyams_content.component.paragraph.interfaces.header import IHeaderParagraph, HEADER_PARAGRAPH_TYPE, \
     HEADER_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(IHeaderParagraph)
-class HeaderParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IHeaderParagraph)
+class HeaderParagraph(BaseParagraph):
     """Header paragraph"""
 
     icon_class = 'fa-download fa-rotate-180'
@@ -89,16 +88,7 @@
 
 
 @vocabulary_config(name=HEADER_PARAGRAPH_RENDERERS)
-class HeaderParagraphRendererVocabulary(SimpleVocabulary):
+class HeaderParagraphRendererVocabulary(RenderersVocabulary):
     """Header paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IHeaderParagraph.providedBy(context):
-            context = HeaderParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(HeaderParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IHeaderParagraph