Adding a Match media filter in Persons filters

Hi,

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

I’ve created two files and modified two others:

_matchesmediafilterbase.py is based on _matcheseventfilterbase.py 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?

Thanks!

@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
MyFilters.__init__(self,
                   caller_locals["filterdb"].get_filters('Family'))

by this

caller_locals = stack[1][0].f_locals  # locals from caller
# the caller has an attribute 'filterdb' which has what we need
MyFilters.__init__(self,
                   caller_locals["filterdb"].get_filters('Media'))

but Gramps had crashed at startup with this error stack:

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