Skip to content

Commit

Permalink
Fix handle attachements when indexing a new File
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Dec 6, 2024
1 parent e45ac79 commit c4cfb4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Changelog
1.5.4 (unreleased)
------------------

- Nothing changed yet.
- Fix handle attachements when indexing a new File.
[cekk]


1.5.3 (2024-12-06)
------------------

- Fix error when trying to get @site service to get site title and make exception more generic.
- Fix handle attachements when indexing a new content and make exception more generic.
[cekk]


Expand Down
12 changes: 9 additions & 3 deletions src/rer/solrpush/utils/solr_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def can_index(item):
return is_right_portal_type(item)


def create_index_dict(item):
def create_index_dict(item, default={}):
"""Restituisce un dizionario pronto per essere 'mandato' a SOLR per
l'indicizzazione.
"""
Expand All @@ -148,7 +148,13 @@ def create_index_dict(item):
# repsonses and can be copied in solr configuration.
continue
field_type = field_infos.get("type")
value = getattr(adapter, field, None)
try:
value = getattr(adapter, field, None)
except Exception:
# if we are in creation and indexing a content with a File, SearchableText
# raise PosKeyError because it tries to read the file too, but the blob
# isn't created yet.
value = default.get(field, None)
if not value and value is not False:
continue
if callable(value):
Expand Down Expand Up @@ -254,7 +260,7 @@ def push_to_solr(item_or_obj):
context = obj
if not can_index(context):
return False
index_dict = create_index_dict(context)
index_dict = create_index_dict(item=context, default=item_or_obj)
attachment = None
if index_dict.get("attachment", None):
attachment = index_dict.pop("attachment", None)
Expand Down

0 comments on commit c4cfb4e

Please sign in to comment.