From: Jérôme <rom...@ya...> - 2010-01-15 13:08:45
|
Benny, Using the same logic on : Filters.Rules._MatchesEventFilterBase Filters.Rules._MatchesFamilyFilterBase Filters.Rules._MatchesPersonFilterBase Filters.Rules._MatchesSourceFilterBase (if this works ...) then this can be merged into one "generic" classname/object Base filter rule (Filters.Rules._MatchesGenericFilterBase) ? Something like : class MatchesGenericFilterBase(MatchesFilterBase): """ Rule that checks against another object filter. """ labels = [_('Classname filter name:')] name = _('Objects with classname matching the <classname filter>') description = _("Matches objects with classname that match the " "specified classname filter name") category = _('General filters') # we want to have this filter show classname filters namespace = 'classname' def prepare(self, db): MatchesFilterBase.prepare(self, db) self.MSF_filt = self.find_filter() def apply(self, db, object): if self.MSF_filt is None : return False classnamelist = [x.ref for x in object.get_classname_references()] for classnamehandle in classnamelist: #check if classname in classname filter if self.MSF_filt.check(db, classnamehandle): return True return False or def apply(self, db, object): filt = self.find_filter() if filt: for (classname, handle) in db.find_backlink_handles( object.get_handle(), ['classname']): if filt.check(db, handle): return True return False Maybe, Note and Media objects could also be added on GenericBase. Family and Place objects seems to use something else (iteration limitions ? design ?). Gramps-3.2 will be less "person-centric" (navigation, list view, etc ...) and I suppose the way to check events (person, family events) is a relic to Gramps pre2.0 ? When 'Event' was not a primary object ? Currently if someone wants to add a rule matching an <object filter>, first he will spend some time to understand how this should work, then will modify the code available on others objects. "Helge's feature request" is something which could also useful for custom filters on report, exporter, (proxy ?), tools. Jérôme Jérôme a écrit : > Benny, > > >> 1. MatchesPersonFilterBase, with only the filter option > done > >> 2. MatchesPersonFilterInFamilyBase, for matching objects that are >> connected to a Family of which one of the parents satisfies a person >> filter. This filter would allow to select from dropdown option: both >> parents, only mother, only father > ... I do not really know how ! > > By keeping the previous approach, I am able to develop what it could be, > but I cannot really test MatchesFamilyFilter on Person (same non-ASCII > crash on Filter as Peter) and I cannot display the Family filters list > (is it this the limitation ?). > > "matches_object.diff" illustrates the general change ! > > So, I suppose this can also inherit through primary objects > (family/<event>, person/<event>, person/<family>, family/<person>, > event/<person>, event/<family>, etc ...) ? > > > Jérôme > > Benny Malengier a écrit : >> 2010/1/13 Brian Matherly <br...@gr...>: >>> Hi Jerome, >>> >>>> Benny Brian, >>>> >>>> >>>> Should I commit a "migration" patch for the match >>>> <object filter> rules ? >>>> http://www.gramps-project.org/bugs/view.php?id=3105 >> >> Jerome, there is something I think is strange: >> >> class MatchesPersonFilterBase >> >> This if the base for filter on event. The filter is defined with: >> >> + labels = [_('Person filter name:'), _('Include Family >> events:')] >> + name = _('Objects of persons matching the <person filter>') >> + description = _("Matches objects of persons matched by the >> specified " >> + "person filter name") >> + category = _('General filters') >> >> on the other hand, the filter MatchesPersonFilter of Event has: >> >> labels = [_('Person filter name:'), _('Include Family events:')] >> name = _('Events of persons matching the <person filter>') >> description = _("Matches events of persons matched by the specified " >> "person filter name") >> category = _('General filters') >> >> So, the second option: Include Family events, has no use in >> MatchesPersonFilterBase, it should only be present in >> Events/MatchesPersonFilter >> >> The correct approach would be: >> 1. MatchesPersonFilterBase, with ony the filter option >> 2. MatchesPersonFilterInFamilyBase, for matching objects that are >> connected to a Family of which one of the parents satisfies a person >> filter. This filter would allow to select from dropdown option: both >> parents, only mother, only father >> 3. Then the current Event/_MatchesPersonFilter, would be done via >> combining two rules where one of the two rules must apply, one >> satisfying above 1., and one satisfying above 2. So you would need to >> inherit both of above filters, but that is not supported at the >> moment. So you could leave the code as present (inheriting only 1. or >> none of the two), and people can make themselves the correct filter >> using the filter editor. >> >> Otherwise, the approach is good. >> >> Benny >>>> Current code is still working, but if someone wants to >>>> reuse code or to add a new rule on object, this could be >>>> useful. >>>> >>>> * code will be on ObjectBase >>>> * labels and rule classes on objects >>>> >>>> >>>> Make the change will give time to test this minors >>>> improvements and/or to revert change if this break too much >>>> things ! I made some quick tests and filters return the same >>>> values. >>>> >>>> >>>> Happy new year ! >>> Sorry I haven't responded to this. I tried to look at it, but filters >>> are not my specialty. I'm not sure I understand what it adds. I think >>> Gerald has some experience with the filters. You might consider >>> asking him. >>> >>> ~Brian >>> >> |