src/pyams_content/component/association/paragraph.py
changeset 555 8e8a14452567
parent 437 4a4482e283df
child 586 28445044f6e3
--- a/src/pyams_content/component/association/paragraph.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/association/paragraph.py	Fri May 25 08:03:41 2018 +0200
@@ -22,26 +22,26 @@
 from pyams_content.component.links.interfaces import ILinkContainerTarget
 from pyams_content.component.paragraph.interfaces import IParagraphFactory
 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.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(IAssociationParagraph, IExtFileContainerTarget, ILinkContainerTarget)
-class AssociationParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IAssociationParagraph)
+class AssociationParagraph(BaseParagraph):
     """Associations paragraph"""
 
     icon_class = 'fa-link'
@@ -91,16 +91,7 @@
 
 
 @vocabulary_config(name=ASSOCIATION_PARAGRAPH_RENDERERS)
-class AssociationParagraphRendererVocabulary(SimpleVocabulary):
+class AssociationParagraphRendererVocabulary(RenderersVocabulary):
     """Associations paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IAssociationParagraph.providedBy(context):
-            context = AssociationParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(AssociationParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IAssociationParagraph