diff --git a/core/src/zeit/workflow/publish_3rdparty.py b/core/src/zeit/workflow/publish_3rdparty.py index e019926a7e..50a8dd2a35 100644 --- a/core/src/zeit/workflow/publish_3rdparty.py +++ b/core/src/zeit/workflow/publish_3rdparty.py @@ -249,10 +249,10 @@ class IgnoreMixin: #: map article attributes to settings attr_setting_mapping = { - 'genre': 'genres', - 'template': 'templates', - 'ressort': 'ressorts', - 'uniqueId': 'uniqueids', + 'genre': ('genres', zeit.content.article.interfaces.IArticleMetadata), + 'template': ('templates', zeit.content.article.interfaces.IArticleMetadata), + 'ressort': ('ressorts', zeit.content.article.interfaces.IArticleMetadata), + 'uniqueId': ('uniqueids', zeit.cms.content.interfaces.ICommonMetadata), } @property @@ -261,15 +261,21 @@ def name(self): return self.__class__.__dict__['grokcore.component.directive.name'] def ignore(self, method): - if self.context.product and self.context.product.is_news: + if ( + zeit.cms.content.interfaces.ICommonMetadata.providedBy(self.context) + and self.context.product + and self.context.product.is_news + ): return True if method == 'publish': for attribute, setting in self.attr_setting_mapping.items(): - if self.is_on_ignorelist(attribute, setting): + if self.is_on_ignorelist(attribute, *setting): return True return False - def is_on_ignorelist(self, attribute, setting): + def is_on_ignorelist(self, attribute, setting, interface): + if not interface.providedBy(self.context): + return False ignore_list = ( zeit.cms.config.get('zeit.workflow', f'{self.name}-ignore-{setting}', '') .lower() @@ -438,7 +444,7 @@ class CenterPageIndexNow(grok.Adapter, IndexNowMixin): grok.name('indexnow') -class DataScienceMixin(PropertiesMixin): +class DataScienceMixin(PropertiesMixin, IgnoreMixin): def _json(self): if self.properties is None: return None @@ -447,15 +453,9 @@ def _json(self): 'body': lxml.etree.tostring(self.context.xml, encoding='unicode'), } - def publish_json(self): - return self._json() - - def retract_json(self): - return {} - @grok.implementer(zeit.workflow.interfaces.IPublisherData) -class ArticleDataScience(grok.Adapter, IgnoreMixin, DataScienceMixin): +class ArticleDataScience(grok.Adapter, DataScienceMixin): grok.context(zeit.content.article.interfaces.IArticle) grok.name('datascience')