# HG changeset patch # User Thierry Florac # Date 1537348553 -7200 # Node ID 0d42d6bc3fb90ff68b2dcc758f60468cfeed2d13 # Parent 471b10c170eb578b0f85bdc7d80a369816f26f6a Check for broken objects while iterating over paragraphs diff -r 471b10c170eb -r 0d42d6bc3fb9 src/pyams_content/component/paragraph/container.py --- a/src/pyams_content/component/paragraph/container.py Wed Sep 19 10:57:47 2018 +0200 +++ b/src/pyams_content/component/paragraph/container.py Wed Sep 19 11:15:53 2018 +0200 @@ -12,24 +12,21 @@ __docformat__ = 'restructuredtext' - -# import standard library - +from ZODB.interfaces import IBroken 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 pyams_content import _ + @implementer(IParagraphContainer) class ParagraphContainer(BTreeOrderedContainer): @@ -46,11 +43,11 @@ if names: for name in names: paragraph = self.get(name) - if (paragraph is not None) and paragraph.visible: + if (paragraph is not None) and (not IBroken.providedBy(paragraph)) and paragraph.visible: yield paragraph else: for paragraph in self.values(): - if not paragraph.visible: + if IBroken.providedBy(paragraph) or not not paragraph.visible: continue if anchors_only and not paragraph.anchor: continue @@ -107,7 +104,7 @@ if not paragraph.visible: continue visible = True - for name, checker in sorted(registry.getAdapters((paragraph, ), IContentChecker), + for name, checker in sorted(registry.getAdapters((paragraph,), IContentChecker), key=lambda x: x[1].weight): if name: output.append('
')