--- a/src/pyams_content/component/illustration/__init__.py Sun Feb 11 12:11:05 2018 +0100
+++ b/src/pyams_content/component/illustration/__init__.py Thu Feb 15 15:08:29 2018 +0100
@@ -16,7 +16,7 @@
# import standard library
# import interfaces
-from pyams_content.component.illustration.interfaces import IIllustrationRenderer, IIllustration, IIllustrationTarget, \
+from pyams_content.component.illustration.interfaces import IIllustration, IIllustrationTarget, \
ILLUSTRATION_KEY
from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
@@ -29,12 +29,12 @@
# import packages
from persistent import Persistent
from pyams_content.features.checker import BaseContentChecker
+from pyams_content.features.renderer import RenderedContentMixin
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,13 +42,12 @@
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 _
@implementer(IIllustration)
-class Illustration(Persistent, Contained):
+class Illustration(Persistent, Contained, RenderedContentMixin):
"""Illustration persistent class"""
title = FieldProperty(IIllustration['title'])
@@ -67,7 +66,7 @@
@data.setter
def data(self, value):
self._data = value
- for data in self._data.values():
+ for data in (self._data or {}).values():
if IImage.providedBy(data):
alsoProvides(data, IResponsiveImage)
@@ -181,18 +180,3 @@
illustration = IIllustration(context, None)
if illustration is not None:
return IContentChecker(illustration)
-
-
-@vocabulary_config(name='PyAMS illustration renderers')
-class IllustrationRendererVocabulary(SimpleVocabulary):
- """Illustration renderer utilities vocabulary"""
-
- def __init__(self, context=None):
- request = check_request()
- translate = request.localizer.translate
- registry = request.registry
- context = Illustration()
- terms = [SimpleTerm(name, title=translate(adapter.label))
- for name, adapter in sorted(registry.getAdapters((context, request), IIllustrationRenderer),
- key=lambda x: x[1].weight)]
- super(IllustrationRendererVocabulary, self).__init__(terms)