# HG changeset patch # User Thierry Florac # Date 1536235222 -7200 # Node ID de7b111fee8ac69b4d57491ae6ab1f00a60058d9 # Parent 33cc538f30a207f77923776dd9a9c6f9c4bc3ee4 Updated method to get selected paragraphs diff -r 33cc538f30a2 -r de7b111fee8a src/pyams_content/component/paragraph/container.py --- a/src/pyams_content/component/paragraph/container.py Thu Sep 06 13:59:39 2018 +0200 +++ b/src/pyams_content/component/paragraph/container.py Thu Sep 06 14:00:22 2018 +0200 @@ -15,21 +15,20 @@ # import standard library -# import interfaces -from pyams_content.component.paragraph.interfaces import IParagraphFactory, IParagraphContainer, \ - IParagraphContainerTarget, PARAGRAPH_CONTAINER_KEY -from pyams_content.features.checker.interfaces import IContentChecker +from zope.interface import implementer from zope.location.interfaces import ISublocations from zope.traversing.interfaces import ITraversable +from pyams_content import _ +# import interfaces +from pyams_content.component.paragraph.interfaces import IParagraphFactory, IParagraphContainer, \ + IParagraphContainerTarget, PARAGRAPH_CONTAINER_KEY # import packages from pyams_content.features.checker import BaseContentChecker +from pyams_content.features.checker.interfaces import IContentChecker from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter from pyams_utils.container import BTreeOrderedContainer from pyams_utils.registry import get_global_registry -from zope.interface import implementer - -from pyams_content import _ @implementer(IParagraphContainer) @@ -54,7 +53,9 @@ has_factory = False for factory_name in factories: factory = registry.queryUtility(IParagraphFactory, name=factory_name) - has_factory = (factory is not None) and (factory.content_type == paragraph.__class__) + has_factory = (factory is not None) and isinstance(paragraph, factory.content_type) + if has_factory: + break if not has_factory: continue yield paragraph