Adding a Match media filter in Persons filters


I’m trying to add a Match media filter in Persons filters.

I’ve created two files and modified two others: is based on from the same directory.

My filter works fine, it returns me people with the selected filter medias but I’ve an issue when creating the filter: media filter selection is not the filters list but just a text box:

If I fill it with any media filter name I have, filter works well:

But, what do I have to change to have media filters list in the rule editor instead of that box?


@PLegoux: I think you have to create your own filter selector, because it’s not supported yet.

@prculley created this filter selector and it’s working fine:

1 Like

I’d tried it.

I’d replaced this

caller_locals = stack[1][0].f_locals  # locals from caller
# the caller has an attribute 'filterdb' which has what we need

by this

caller_locals = stack[1][0].f_locals  # locals from caller
# the caller has an attribute 'filterdb' which has what we need

but Gramps had crashed at startup with this error stack:

5168: ERROR: line 157: Unhandled exception
Traceback (most recent call last):
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\", line 794, in do_activate
    Gramps(self.argparser, self)
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\", line 603, in __init__
    from .viewmanager import ViewManager
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\", line 67, in <module>
    from gramps.cli.grampscli import CLIManager
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\cli\", line 67, in <module>
    from gramps.gen.filters import reload_custom_filters
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gen\filters\", line 28, in <module>
    from ._filterlist import FilterList
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gen\filters\", line 37, in <module>
    from ._filterparser import FilterParser
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gen\filters\", line 36, in <module>
    from . import rules
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gen\filters\rules\", line 81, in <module>
    from ._matchesmediafilterbase import MatchesMediaFilterBase
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gen\filters\rules\", line 38, in <module>
    from ....gui.editors.filtereditor import MyFilters
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\editors\", line 30, in <module>
    from .editfamily import EditFamily
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\editors\", line 94, in <module>
    SelectPerson = SelectorFactory('Person')
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\selectors\", line 26, in SelectorFactory
    from .selectperson import SelectPerson
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\selectors\", line 37, in <module>
    from ..views.treemodels import PeopleBaseModel, PersonTreeModel
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\views\treemodels\", line 25, in <module>
    from .peoplemodel import PeopleBaseModel, PersonListModel, PersonTreeModel
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\views\treemodels\", line 63, in <module>
    from .flatbasemodel import FlatBaseModel
  File "C:\Program Files\GrampsAIO64-5.1.1\gramps\gui\views\treemodels\", line 73, in <module>
    from gramps.gen.filters import SearchFilter, ExactSearchFilter
ImportError: cannot import name 'SearchFilter'

It seems to look at the familly and/or person structures (?) which previous code was design for.

I’ve tried that too but it don’t change anything (f_locals -> m_locals):

caller_locals = stack[1][0].m_locals  # locals from caller