src/pyams_content/component/paragraph/keynumber.py
changeset 555 8e8a14452567
parent 527 5dd1aa8bedd9
child 558 d9c6b1d7fefa
--- a/src/pyams_content/component/paragraph/keynumber.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/keynumber.py	Fri May 25 08:03:41 2018 +0200
@@ -33,8 +33,9 @@
 from pyams_catalog.utils import index_object
 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory, BaseParagraphContentChecker
 from pyams_content.features.checker import BaseContentChecker
-from pyams_content.features.renderer import RenderedContentMixin, IContentRenderer
+from pyams_content.features.renderer import RenderersVocabulary
 from pyams_utils.adapter import adapter_config, ContextAdapter
+from pyams_utils.factory import factory_config
 from pyams_utils.registry import get_current_registry, get_utility, utility_config
 from pyams_utils.request import check_request
 from pyams_utils.traversing import get_parent
@@ -46,7 +47,6 @@
 from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
 from zope.location import locate
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_content import _
 
@@ -206,7 +206,8 @@
 
 
 @implementer(IKeyNumberParagraph)
-class KeyNumberParagraph(RenderedContentMixin, BaseParagraph):
+@factory_config(provided=IKeyNumberParagraph)
+class KeyNumberParagraph(BaseParagraph):
     """Key numbers paragraph"""
 
     icon_class = 'fa-list-ol'
@@ -256,16 +257,7 @@
 
 
 @vocabulary_config(name=KEYNUMBER_PARAGRAPH_RENDERERS)
-class KeyNumberParagraphRendererVocabulary(SimpleVocabulary):
+class KeyNumberParagraphRendererVocabulary(RenderersVocabulary):
     """Key numbers paragraph renderers vocabulary"""
 
-    def __init__(self, context=None):
-        request = check_request()
-        translate = request.localizer.translate
-        registry = request.registry
-        if not IKeyNumberParagraph.providedBy(context):
-            context = KeyNumberParagraph()
-        terms = [SimpleTerm(name, title=translate(adapter.label))
-                 for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
-                                             key=lambda x: x[1].weight)]
-        super(KeyNumberParagraphRendererVocabulary, self).__init__(terms)
+    content_interface = IKeyNumberParagraph