Updated method to get selected paragraphs
authorThierry Florac <thierry.florac@onf.fr>
Thu, 06 Sep 2018 14:00:22 +0200
changeset 928 de7b111fee8a
parent 927 33cc538f30a2
child 929 1440d627e103
Updated method to get selected paragraphs
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