Best Practice for Calling _post_init() in EditPerson Class and Extending It in a Gramplet

How can I properly call the _post_init() method of the EditPerson class from the file /gramps/gui/editors/editperson.py in my gramplet so that the standard logic of this method runs first, followed by additional code from the gramplet?

Is monkey patching an acceptable solution for the Gramps project, and will it work effectively in this context? This is my first experience.

Methods with names starting with a single underscore are protected. They should only be used in sub-classes.

2 Likes

What about the same thing but for unprotected method?

    def add(self, *obj):
        """
        Add a new person to the database.
        """
        person = Person()
        # the editor requires a surname
        person.primary_name.add_surname(Surname())
        person.primary_name.set_primary_surname(0)
        
        try:
            EditPerson(self.dbstate, self.uistate, [], person)
        except WindowActiveError:
            pass

What is recommended way to execute gramplet script after the method last row? Looks like signals can not help with it because EditPerson has not created a new person in the DB yet.

You should restrict yourself to using public methods only.

In this case, consider using an editor callback.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.