Skip to content

Commit

Permalink
improved check on None blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-andreotti committed Jan 15, 2025
1 parent d2fc39b commit 2d4416d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/redturtle/volto/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,9 @@ def should_reindex(blocks):
if i % 100 == 0:
logger.info(f"Progress: {i}/{tot}")

if should_reindex(blocks=getattr(obj, "blocks", {})):
reindex = True
if getattr(obj, "blocks", {}):
if should_reindex(blocks=getattr(obj, "blocks", {})):
reindex = True
for schema in iterSchemata(obj):
for name, field in getFields(schema).items():
if name == "blocks":
Expand All @@ -576,9 +577,10 @@ def should_reindex(blocks):
value = field.get(obj)
try:
blocks = value.get("blocks", {})
if should_reindex(blocks):
reindex = True
break
if blocks:
if should_reindex(blocks):
reindex = True
break
except AttributeError:
logger.warning(
f"[RICHTEXT] - {brain.getURL()} (should not reindexed)"
Expand Down

0 comments on commit 2d4416d

Please sign in to comment.