How would you prompt for the location or person? It would be nice if custom filters could do that somehow. (If they can, then it’s something I’ve been missing out on.)
Some of the custom filters I use as building blocks for others include these:
Active person [uses the Active person rule]
Bookmarked people [uses the Bookmarked people rule]
Default person (or home person) [uses the Home person rule]
It would also be nice if it were easy to see which custom filters use a given filter rule or other custom filter (without having to go into the xml file to figure it out).
One of the nice extras in the Plugin Manager Enhanced V2 is the (debug mode) Edit button that opens the plugin’s source file in a whatever editor is tied to .py extensions. This simplifies inspecting the code.
Also very nice feature is in Kari’s prototype Filter2 gramplets. They scrape all the settings in the Filter gramplet to build a custom filter.
Also, his experimental FilterParams tool makes inspection in the GUI easy. (Particularly since it isn’t like the Gramps Filter Editor that doesn’t let you switch the category silos for the filters.
0012830 Filter Rules are missing basic rules for inter object working
You missed this one. The whole idea behind filters appears to be “To obtain a list of People”.
But if you want to start with a list of people and end with a list of events or citations, then you start hitting obstacles very quickly.
I realise that having a filter rule for every occasion would result in a very long list in deed.
Yes. Eventually, we’ll need some sort of codex/grimoire/formulary/Rulebook GUI for finding, instruction & sharing of Filter Rules.
Hopefully, there will be competing systems of organization.
Like the OCLC’s Query Collection, when the database grows too complex (they have 856 bibliographical fields describing WorldCat holdings) it becomes difficult to grok organizational potential.
I’m not a developer but as stated there is no limit to the number of filters that users may want. I think a longer term strategy might be to put the effort into moving gramps to a full sql based system, then users can develop any sql query they need.
The work could be divided up into chunks. As I understand it, a lot of work has been done defining the schema already.
The idea of listing the requested filters is so we might begin a discussion of how to do the requested filters without creating a glut of addon rules.
And so that some of these MantisBT requests can be closed with workaround. Although we might determine that some are foundation rules that actually DO need to be added.
Sorry, I forgot about the Super Tool. It isn’t loaded on my system so I have never used it. Out of sight out of mind. I’m a guy that just likes to go to the menu and find the tools that I can use.
I have tried the “Supertool” and failed to design the filter of my choice. Its lack of any instructions, hints or tips deters me and, no doubt, many others, from using it.
Also, using the Filter+ replacements for the various Filter Gramplets can be used as a template. While the Define filter scrapes the parameters entered for the various fields… so exploring the new (as yet unnamed) Custom Filter also exposes the pertinent rules (and the combination of rules) needed to search for a particular item.
In the following request, a user wanted a rule to find Events with a precise date.
I ended up creating 3 rules:
find Events with precise date
find Events with approximated dates
find Events with no/blank/null dates
Before SuperTool:
sharing a new rule required creating an addon. A new addon meant figuring out how to code a “Rule” addon and its plugin registration file. When I experimented with that to build 3 Event date rules, that meant about 20 lines of code and 16 lines of registration per additional Rule. Then, it had to be submitted for approval in the Addon Manager distribution system.
Experimenting with SuperTool:
But each of my experimental filters only takes 3 lines in SuperTool. And one of those is multiline comment.
The hardest part was finding the feature that checks the Date object in the Gramps developer documentation in Sphinx. In this case, I was looking for functions related to the date object. The 2 functions that were relevant were is_regular() and is_empty()
“Menu → Save as a filter” in SuperTool makes a Custom Filter based on ‘generic rule’:
3 working fields also means just 3 fields using the SuperTool rule addon: Generic Rule.
Here’s the ‘generic rule’. In “Statements”, it sets a variable to be the Date object from the Event. Then in “Rule”, it checks if that Date object variable contains a ‘regular’ date. (A ‘regular’ date is a single exact date, i.e. not text-only, not a range or a span, not estimated/calculated, not a special calendar, not dual-dated, no special new year day, not about/before/after date. And by exact, it has a non-zero year, month, AND day.)
As a custom filter using the SuperTool Generic addon rule:
Here’s a custom_filters.xml (from the Gramps User Directory) that contains all 3 “Event” category filter rules:
<?xml version="1.0" encoding="utf-8"?>
<filters>
<object type="Event">
<filter name="SuperTool_RegularDates" function="and">
<rule class="GenericFilterRule_Event" use_regex="False">
<arg value="dateobject.is_regular()"/>
<arg value="# Return "True" if the date is a regular date.<br># The regular date is a single exact date, i.e. not text-only, not a range or a span, <br># not estimated/calculated, not about/before/after date, and having a year, <br># month, and day all non-zero.<br># see https://gramps-project.org/docs/gen/gen_lib.html#gramps.gen.lib.date.Date.is_regular"/>
<arg value="dateobject=self.event.get_date_object()"/>
</rule>
</filter>
<filter name="SuperTool_IrregularDates" function="and">
<rule class="GenericFilterRule_Event" use_regex="False">
<arg value="not (event.get_date_object().is_regular() or event.get_date_object().is_empty())"/>
<arg value="# Return True if matches events having a irregular date but not a blank date)<br># see https://gramps-project.org/docs/gen/gen_lib.html#gramps.gen.lib.date.Date.is_regular"/>
<arg value="dateobject=self.event.get_date_object()"/>
</rule>
</filter>
<filter name="SuperTool_Blank_Dates" function="and">
<rule class="GenericFilterRule_Event" use_regex="False">
<arg value="event.get_date_object().is_empty()"/>
<arg value="# Return "True" if the date is a blank date."/>
<arg value="dateobject=self.event.get_date_object()"/>
</rule>
</filter>
</object>
</filters>
The irregular rule threw an error. In the second line there are two semicolons (;) together that it did not like. Made it a single semicolon and it ran just fine.
Is the irregular rule supposed to include the null date entries?
Thanks @DaveSch , I just updated the previous posting to eliminate the error. (It had been a tweaked version that dropped the null tests. I needed to revert.)