Gramps has a number of methods for getting data from the database. The available methods are a combination of
- record identifier
- handle
- gramps_id
- result type
- object
- DataDict
- iterator of object, handle or data
but there is little consistency in the naming of these methods. This was previously discussed in late 2024 but no consensus was reached. Personally, I find this lack of consistency frustrating so I’m picking up the baton in the hope that we can reach a consensus this time.
Proposal
| Current | Proposed |
|---|---|
get_person_from_handle |
get_person |
get_person_from_gramps_id |
get_person_from_gramps_id |
get_raw_person_data |
get_person_data |
_get_raw_person_from_id_data |
get_person_data_from_gramps_id |
iter_person_handles |
iter_person_handles |
iter_people |
iter_person |
_iter_raw_person_data |
iter_person_data |
with similar changes for the other object types.
Summary of changes
- Two internal methods are made public (
_get_raw_person_from_id_data,_iter_raw_person_data)
There does not appear to be a reason for these methods to remain internal - The singular form is used in method names (
personrather thanpeople).
Hopefully making it easier for non-native English speakers - handle is the primary record identifier and so
_from_handleis dropped from method names.
Less typing is always a good thing _rawis dropped from methods.
It is superfluous given_datais also present in the method name.
Proposed timeline
| Gramp version | Status |
|---|---|
| 6.1 | Proposed methods implemented. Current methods remain available. Codebase left as-is. |
| 6.2 | Codebase updated to use proposed methods. Current methods deprecated but still available. All addons updated. |
| 6.3 | Deprecated methods removed. |
6.1, 6.2, 6.3 just represent future releases. The actual version numbers may vary.
A staggered implementation will make it easier for any addon developers that support multiple gramps versions from a single code base. I welcome proposals to move more quickly if this is not a concern.
Previous
- discussion: Proposal for database method renaming
- pull request: Update database method names by dsblank · Pull Request #1829.
We could look to combine handle and gramps_id forms of methods either via @singledispatch or parameter type inspection i.e. if isinstance(key, PersonHandle): ... elif isinstance(key, PersonGrampsID): ... Personally I’d prefer to make some improvement now.
Your comments sought.