# HG changeset patch # User Thierry Florac # Date 1537524999 -7200 # Node ID 141dc5ad83d6bec05eb7cf9db6352c5d12bd6d66 # Parent 7108d28758c32c7470476cfa6fdd5ee754a59d1f Updated base interfaces diff -r 7108d28758c3 -r 141dc5ad83d6 src/pyams_content/component/illustration/__init__.py --- a/src/pyams_content/component/illustration/__init__.py Fri Sep 21 09:32:00 2018 +0200 +++ b/src/pyams_content/component/illustration/__init__.py Fri Sep 21 12:16:39 2018 +0200 @@ -12,15 +12,11 @@ __docformat__ = 'restructuredtext' - -# import standard library - -# import packages from persistent import Persistent from pyramid.events import subscriber from pyramid.threadlocal import get_current_registry from zope.container.contained import Contained -from zope.interface import implementer, alsoProvides +from zope.interface import alsoProvides, implementer from zope.lifecycleevent import ObjectAddedEvent from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent from zope.location.interfaces import ISublocations @@ -28,19 +24,18 @@ from zope.traversing.interfaces import ITraversable from pyams_content import _ -# import interfaces -from pyams_content.component.illustration.interfaces import IIllustration, IIllustrationTarget, \ - ILLUSTRATION_KEY, ILLUSTRATION_RENDERERS, IBasicIllustration, IBasicIllustrationTarget, BASIC_ILLUSTRATION_KEY, \ - ILinkIllustrationTarget, LINK_ILLUSTRATION_KEY, ILinkIllustration +from pyams_content.component.illustration.interfaces import BASIC_ILLUSTRATION_KEY, IBasicIllustration, \ + IBasicIllustrationTarget, IIllustration, IIllustrationTarget, IIllustrationTargetBase, ILLUSTRATION_KEY, \ + ILLUSTRATION_RENDERERS, ILinkIllustration, ILinkIllustrationTarget, LINK_ILLUSTRATION_KEY from pyams_content.features.checker import BaseContentChecker -from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE +from pyams_content.features.checker.interfaces import IContentChecker, MISSING_LANG_VALUE, MISSING_VALUE from pyams_content.features.renderer import RenderedContentMixin, RenderersVocabulary from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage -from pyams_i18n.interfaces import INegotiator, II18n, II18nManager +from pyams_i18n.interfaces import II18n, II18nManager, INegotiator from pyams_i18n.property import I18nFileProperty -from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter +from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter from pyams_utils.factory import factory_config -from pyams_utils.registry import query_utility, get_utility, get_global_registry +from pyams_utils.registry import get_global_registry, get_utility, query_utility from pyams_utils.request import check_request from pyams_utils.traversing import get_parent from pyams_utils.vocabulary import vocabulary_config @@ -76,6 +71,15 @@ return False +@implementer(IIllustration) +@factory_config(provided=IIllustration) +class Illustration(RenderedContentMixin, BasicIllustration): + """Illustration persistent class""" + + description = FieldProperty(IIllustration['description']) + renderer = FieldProperty(IIllustration['renderer']) + + @adapter_config(context=IBasicIllustrationTarget, provides=IIllustration) def basic_illustration_factory(context): """Basic illustration factory""" @@ -88,15 +92,6 @@ callback=illustration_callback) -@implementer(IIllustration) -@factory_config(provided=IIllustration) -class Illustration(RenderedContentMixin, BasicIllustration): - """Illustration persistent class""" - - description = FieldProperty(IIllustration['description']) - renderer = FieldProperty(IIllustration['renderer']) - - @adapter_config(context=IIllustrationTarget, provides=IIllustration) def illustration_factory(context): """Illustration factory""" @@ -150,7 +145,7 @@ update_illustration_properties(illustration) -@adapter_config(name='illustration', context=IBasicIllustrationTarget, provides=ITraversable) +@adapter_config(name='illustration', context=IIllustrationTargetBase, provides=ITraversable) class IllustrationNamespace(ContextAdapter): """++illustration++ namespace adapter""" @@ -159,13 +154,13 @@ return registry.queryAdapter(self.context, IIllustration, name=name) -@adapter_config(name='illustration', context=IBasicIllustrationTarget, provides=ISublocations) +@adapter_config(name='illustration', context=IIllustrationTargetBase, provides=ISublocations) class IllustrationSublocations(ContextAdapter): """Illustration sub-locations adapter""" def sublocations(self): registry = get_global_registry() - for name, adapter in registry.getAdapters((self, ), IBasicIllustration): + for name, adapter in registry.getAdapters((self,), IBasicIllustration): yield adapter @@ -184,7 +179,7 @@ langs = manager.get_languages() else: negotiator = get_utility(INegotiator) - langs = (negotiator.server_language, ) + langs = (negotiator.server_language,) missing_value = translate(MISSING_VALUE) missing_lang_value = translate(MISSING_LANG_VALUE) i18n = II18n(self.context) @@ -203,7 +198,7 @@ output.append(missing_lang_value.format(field=translate(IIllustration[attr].title), lang=lang)) if has_data: - for attr in ('author', ): + for attr in ('author',): value = getattr(self.context, attr) if not value: output.append(missing_value.format(field=translate(IIllustration[attr].title))) diff -r 7108d28758c3 -r 141dc5ad83d6 src/pyams_content/component/illustration/interfaces/__init__.py --- a/src/pyams_content/component/illustration/interfaces/__init__.py Fri Sep 21 09:32:00 2018 +0200 +++ b/src/pyams_content/component/illustration/interfaces/__init__.py Fri Sep 21 12:16:39 2018 +0200 @@ -19,7 +19,8 @@ from pyams_content import _ from pyams_content.component.paragraph.interfaces import IBaseParagraph from pyams_content.features.renderer.interfaces import IRenderedContent -from pyams_i18n.schema import I18nTextLineField, I18nTextField, I18nThumbnailMediaField +from pyams_i18n.schema import I18nTextField, I18nTextLineField, I18nThumbnailMediaField + # # Illustration @@ -72,7 +73,11 @@ """Navigation link illustration interface""" -class IBasicIllustrationTarget(IAttributeAnnotatable): +class IIllustrationTargetBase(IAttributeAnnotatable): + """Illustration target base interface""" + + +class IBasicIllustrationTarget(IIllustrationTargetBase): """Basic illustration target marker interface""" @@ -80,7 +85,7 @@ """Illustration target interface""" -class ILinkIllustrationTarget(IBasicIllustrationTarget): +class ILinkIllustrationTarget(IIllustrationTargetBase): """Link illustration target interface"""