My first gramplet (Associations QuickReport) - help please!

I thought I would try writing a Quickview gramplet to show the associations of a person. I realize there is already an associations tool, but I think it would be handy to have a gramplet to show the associations of the current person, without have to edit the person to see them.

I copied the example quickview for siblings but got stuck trying to find the simple access version of a personref for the associations. Maybe there isn’t one?

stab = QuickTable(sdb)
sdoc.header1(_("Associations"))
stab.columns(_("Name"), 
             _("ID"), 
             _("Association"))

# loop through each association of the person
for _?_ in sdb._?_(person)
     stab.row(_?_,
            sdb.name(_?_),
	sdb.gid(_?_),
	sdb.(_?_))
         document.has_data = True
stab.write(sdoc)

I’m also wondering if I’m using associations correctly. I have an obituary which mentions the deceased woman’s grandson. But I don’t know which of her children he was a child of. So I want to associate them. I created an association (while editing him), pointing to her, with the association as “Grandmother”, which I thought was the correct way to do it. But the association tool says that he is the grandmother of her.

a grandkid of unknown parentage can be added differently.

Add a placeholder offspring named ‘indeterminate child’ of unknown gender and add the grandkid. If the known person is a grandson, the surname suggests the missing parent was a daughter or son.

Eventually, you should be able to merge the fictitious person or identify them. In the meantime, the grandkid shows up in the tree.

@GeorgeWilmes No unfortunately the simple access API does not provide allow acess to person associations. I’ve put together some code how it could look like, I hope that helps.

It uses the function get_associations which acesses the database without simple access API and returns a list of tuples containing the associate person and the relationship information.

    from gramps.gen.simple import SimpleAccess, SimpleDoc
    from gramps.gui.plug.quick import QuickTable
    from gramps.gen.const import GRAMPS_LOCALE as glocale
    _ = glocale.translation.gettext


    def run(database, document, person):
        """Quickview for person associations."""
        sdoc = SimpleDoc(document)
        sdb = SimpleAccess(database)
        stab = QuickTable(document)

        sdoc.title(_("Associations"))
        sdoc.paragraph("")
        stab.columns(_("Name"),
                     _("ID"),
                     _("Association"))
        
        # we need some help here
        all_associations = get_associations(database, person)

        # loop through each association from the returned list
        for association in all_associations:
            associate = association[0]
            relationship = association[1]
            stab.row(
                sdb.name(associate),
                sdb.gid(associate),
                relationship)

        stab.write(sdoc)


    def get_associations(database, person):
        """Return a list of all associations of a person."""
        associations_list = list()
        for person_ref in person.get_person_ref_list():
            person = database.get_person_from_handle(person_ref.ref)
            relationship = person_ref.get_relation()
            associations_list.append((person, relationship))
        return associations_list
1 Like

It works! Thank you so much, @Mattkmmr.

@emyoulation, your suggestion is good for a fairly close relation such as a grandchild. I am also thinking of using this approach for more distant unknown relations such as DNA matches. I am still confused about the output of the Associations Tool, specifically the column heading “Of” which makes it seem like the interpretation of the relationship is backwards, or that I have set it up incorrectly. Again, for my example, person A is the grandson and person B is the grandmother. I edited person A and added an association to person B with the relation as “Grandmother”. Is that not right?

From everything I’ve seen, Yes… you would have to to add reciprocal Associations to ensure you can find both terminating Persons from either direction.

Reciprocal Associations feels too much like the agony of double-entry bookkeeping for me to suggest someone use the feature in this way extensively. If the Associations automatically embedded a reciprocal entry, it would be different.

So… as an alternative work round, can you suppose that the linking pseudo person can be a multi-generational placeholder?

The placeholder workaround would not allow Gramps to correctly calculate the degrees of separation for the relationship but the connection would show up in graphs & pedigree charts. And it would be easy to insert people in-between. Once all the people were in, the placeholder workaround resolves itself automatically. (The reciprocal Associations would have to be remembered or rediscovered & then cleaned manually.)

I’m currently recording my DNA matches with a custom “DNA” Event which is shared between me and the other person. As a date I enter when I found this match, for the place I enter the testing company and in the description I enter “total cM”, “number od segments” and “cM of largest segment”. For more detailed data I use notes added to this event.

2 Likes

:exploding_head:ooOOooh! A Shared event would be much better than having to juggle 2 reciprocal Associations or the fiction of a pseudo Person.

You could set up a Form with those items as Attributes too. It’d be awkward for the person selection but more have search/sort potential that an unstructured Description.