From 3c75de23270021a543cd21e53da9aa11468a87a5 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Tue, 15 Jan 2013 10:18:28 +0000 Subject: [PATCH] Filter was not working, we need to query global variable when we need it, not once at start svn: r21128 --- gramps/gen/filters/_filterlist.py | 1 + .../gen/filters/rules/_matchesfilterbase.py | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gramps/gen/filters/_filterlist.py b/gramps/gen/filters/_filterlist.py index 0f86c341a..0641015ee 100644 --- a/gramps/gen/filters/_filterlist.py +++ b/gramps/gen/filters/_filterlist.py @@ -111,6 +111,7 @@ class FilterList(object): parser.parse(the_file) the_file.close() except (IOError, OSError): + print("IO/OSError in _filterlist.py") pass except SAXParseException: print("Parser error") diff --git a/gramps/gen/filters/rules/_matchesfilterbase.py b/gramps/gen/filters/rules/_matchesfilterbase.py index 8a6a149ad..a47ac3e94 100644 --- a/gramps/gen/filters/rules/_matchesfilterbase.py +++ b/gramps/gen/filters/rules/_matchesfilterbase.py @@ -34,7 +34,9 @@ LOG = logging.getLogger(".filter") # GRAMPS modules # #------------------------------------------------------------------------- -from .. import CustomFilters +# we need global variableCustomFilters, so we need to query gramps.gen.filters +# when we need this variable, not import it at the start! +import gramps.gen.filters from . import Rule #------------------------------------------------------------------------- @@ -50,15 +52,14 @@ class MatchesFilterBase(Rule): Subclasses need to define the namespace class attribute. """ - labels = [_('Filter name:')] name = 'Objects matching the ' description = "Matches objects matched by the specified filter name" category = _('General filters') def prepare(self, db): - if CustomFilters: - filters = CustomFilters.get_filters_dict(self.namespace) + if gramps.gen.filters.CustomFilters: + filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace) if self.list[0] in filters: filt = filters[self.list[0]] for rule in filt.flist: @@ -71,16 +72,16 @@ class MatchesFilterBase(Rule): % self.list[0]) def reset(self): - if CustomFilters: - filters = CustomFilters.get_filters_dict(self.namespace) + if gramps.gen.filters.CustomFilters: + filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace) if self.list[0] in filters: filt = filters[self.list[0]] for rule in filt.flist: rule.requestreset() def apply(self, db, obj): - if CustomFilters: - filters = CustomFilters.get_filters_dict(self.namespace) + if gramps.gen.filters.CustomFilters: + filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace) if self.list[0] in filters: filt = filters[self.list[0]] return filt.check(db, obj.handle) @@ -90,8 +91,8 @@ class MatchesFilterBase(Rule): """ Return the selected filter or None. """ - if CustomFilters: - filters = CustomFilters.get_filters_dict(self.namespace) + if gramps.gen.filters.CustomFilters: + filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace) if self.list[0] in filters: return filters[self.list[0]] return None