--- a/src/pyams_content/component/illustration/__init__.py Fri Mar 02 13:42:41 2018 +0100
+++ b/src/pyams_content/component/illustration/__init__.py Fri Mar 02 13:48:23 2018 +0100
@@ -17,7 +17,7 @@
# import interfaces
from pyams_content.component.illustration.interfaces import IIllustration, IIllustrationTarget, \
- ILLUSTRATION_KEY
+ ILLUSTRATION_KEY, ILLUSTRATION_RENDERERS
from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
from pyams_i18n.interfaces import INegotiator, II18n, II18nManager
@@ -29,12 +29,13 @@
# import packages
from persistent import Persistent
from pyams_content.features.checker import BaseContentChecker
-from pyams_content.features.renderer import RenderedContentMixin
+from pyams_content.features.renderer import RenderedContentMixin, IContentRenderer
from pyams_i18n.property import I18nFileProperty
from pyams_utils.adapter import adapter_config, ContextAdapter
from pyams_utils.registry import query_utility, get_utility
from pyams_utils.request import check_request
from pyams_utils.traversing import get_parent
+from pyams_utils.vocabulary import vocabulary_config
from pyramid.events import subscriber
from pyramid.threadlocal import get_current_registry
from zope.container.contained import Contained
@@ -42,6 +43,7 @@
from zope.lifecycleevent import ObjectCreatedEvent, ObjectAddedEvent
from zope.location import locate
from zope.schema.fieldproperty import FieldProperty
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from pyams_content import _
@@ -180,3 +182,19 @@
illustration = IIllustration(context, None)
if illustration is not None:
return IContentChecker(illustration)
+
+
+@vocabulary_config(name=ILLUSTRATION_RENDERERS)
+class IllustrationRendererVocabulary(SimpleVocabulary):
+ """Illustration renderers vocabulary"""
+
+ def __init__(self, context=None):
+ request = check_request()
+ translate = request.localizer.translate
+ registry = request.registry
+ if not IIllustration.providedBy(context):
+ context = Illustration()
+ terms = [SimpleTerm(name, title=translate(adapter.label))
+ for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
+ key=lambda x: x[1].weight)]
+ super(IllustrationRendererVocabulary, self).__init__(terms)