Skip to content

Commit

Permalink
Implement find_backlink_handles
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Jan 4, 2025
1 parent cf89f62 commit 87a8a58
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions gramps_webapi/api/people_families_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

"""A proxy database class optionally caching people and families."""

from typing import Generator

from gramps.gen.proxy.proxybase import ProxyDbBase
from gramps.gen.db import DbReadBase
from gramps.gen.lib import Person, Family
Expand Down Expand Up @@ -54,3 +56,29 @@ def get_family_from_handle(self, handle: str) -> Family:
if handle in self._family_cache:
return self._family_cache[handle]
return self.db.get_family_from_handle(handle)

def find_backlink_handles(
self, handle, include_classes=None
) -> Generator[tuple[str, str], None, None]:
"""
Find all objects that hold a reference to the object handle.
Returns an iterator over a list of (class_name, handle) tuples.
:param handle: handle of the object to search for.
:type handle: str database handle
:param include_classes: list of class names to include in the results.
Default is None which includes all classes.
:type include_classes: list of class names
This default implementation does a sequential scan through all
the primary object databases and is very slow. Backends can
override this method to provide much faster implementations that
make use of additional capabilities of the backend.
Note that this is a generator function, it returns a iterator for
use in loops. If you want a list of the results use::
result_list = list(find_backlink_handles(handle))
"""
return self.db.find_backlink_handles(handle, include_classes)

0 comments on commit 87a8a58

Please sign in to comment.