2626
2727from flask import current_app
2828from gramps .gen .db .base import DbReadBase
29- from gramps .gen .lib import Name
29+ from gramps .gen .lib import Name , Place
3030from whoosh import index
3131from whoosh .fields import BOOLEAN , DATETIME , ID , TEXT , Schema
3232from whoosh .qparser import FieldsPlugin , MultifieldParser , QueryParser
@@ -53,7 +53,12 @@ def object_to_strings(obj) -> Tuple[str, str]:
5353 # repositories and notes currently don't have gramps_id on their
5454 # text_data_list, so it is added here explicitly if missing
5555 strings .append (obj .gramps_id )
56- for child_obj in obj .get_text_data_child_list ():
56+ text_data_child_list = obj .get_text_data_child_list ()
57+ if isinstance (obj , Place ) and obj .name not in text_data_child_list :
58+ # fix necessary for Gramps 5.1
59+ # (see https://github.com/gramps-project/gramps-webapi/issues/245)
60+ text_data_child_list .append (obj .name )
61+ for child_obj in text_data_child_list :
5762 if hasattr (child_obj , "get_text_data_list" ):
5863 if hasattr (child_obj , "private" ) and child_obj .private :
5964 private_strings += child_obj .get_text_data_list ()
@@ -93,7 +98,9 @@ def obj_strings_from_handle(
9398 return None
9499
95100
96- def iter_obj_strings (db_handle : DbReadBase ,) -> Generator [Dict [str , Any ], None , None ]:
101+ def iter_obj_strings (
102+ db_handle : DbReadBase ,
103+ ) -> Generator [Dict [str , Any ], None , None ]:
97104 """Iterate over object strings in the whole database."""
98105 for class_name in PRIMARY_GRAMPS_OBJECTS :
99106 iter_method = db_handle .method ("iter_%s_handles" , class_name )
@@ -263,7 +270,8 @@ def format_hit(hit: Hit) -> Dict[str, Any]:
263270 }
264271
265272 def _get_sorting (
266- self , sort : Optional [List [str ]] = None ,
273+ self ,
274+ sort : Optional [List [str ]] = None ,
267275 ) -> Optional [List [FieldFacet ]]:
268276 """Get the appropriate field facets for sorting."""
269277 if not sort :
0 commit comments