Filter was not working, we need to query global variable when we need it, not once at start
svn: r21128
This commit is contained in:
parent
ca287ac12e
commit
3c75de2327
@ -111,6 +111,7 @@ class FilterList(object):
|
|||||||
parser.parse(the_file)
|
parser.parse(the_file)
|
||||||
the_file.close()
|
the_file.close()
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
|
print("IO/OSError in _filterlist.py")
|
||||||
pass
|
pass
|
||||||
except SAXParseException:
|
except SAXParseException:
|
||||||
print("Parser error")
|
print("Parser error")
|
||||||
|
@ -34,7 +34,9 @@ LOG = logging.getLogger(".filter")
|
|||||||
# GRAMPS modules
|
# 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
|
from . import Rule
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -50,15 +52,14 @@ class MatchesFilterBase(Rule):
|
|||||||
Subclasses need to define the namespace class attribute.
|
Subclasses need to define the namespace class attribute.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
labels = [_('Filter name:')]
|
labels = [_('Filter name:')]
|
||||||
name = 'Objects matching the <filter>'
|
name = 'Objects matching the <filter>'
|
||||||
description = "Matches objects matched by the specified filter name"
|
description = "Matches objects matched by the specified filter name"
|
||||||
category = _('General filters')
|
category = _('General filters')
|
||||||
|
|
||||||
def prepare(self, db):
|
def prepare(self, db):
|
||||||
if CustomFilters:
|
if gramps.gen.filters.CustomFilters:
|
||||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||||
if self.list[0] in filters:
|
if self.list[0] in filters:
|
||||||
filt = filters[self.list[0]]
|
filt = filters[self.list[0]]
|
||||||
for rule in filt.flist:
|
for rule in filt.flist:
|
||||||
@ -71,16 +72,16 @@ class MatchesFilterBase(Rule):
|
|||||||
% self.list[0])
|
% self.list[0])
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
if CustomFilters:
|
if gramps.gen.filters.CustomFilters:
|
||||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||||
if self.list[0] in filters:
|
if self.list[0] in filters:
|
||||||
filt = filters[self.list[0]]
|
filt = filters[self.list[0]]
|
||||||
for rule in filt.flist:
|
for rule in filt.flist:
|
||||||
rule.requestreset()
|
rule.requestreset()
|
||||||
|
|
||||||
def apply(self, db, obj):
|
def apply(self, db, obj):
|
||||||
if CustomFilters:
|
if gramps.gen.filters.CustomFilters:
|
||||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||||
if self.list[0] in filters:
|
if self.list[0] in filters:
|
||||||
filt = filters[self.list[0]]
|
filt = filters[self.list[0]]
|
||||||
return filt.check(db, obj.handle)
|
return filt.check(db, obj.handle)
|
||||||
@ -90,8 +91,8 @@ class MatchesFilterBase(Rule):
|
|||||||
"""
|
"""
|
||||||
Return the selected filter or None.
|
Return the selected filter or None.
|
||||||
"""
|
"""
|
||||||
if CustomFilters:
|
if gramps.gen.filters.CustomFilters:
|
||||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||||
if self.list[0] in filters:
|
if self.list[0] in filters:
|
||||||
return filters[self.list[0]]
|
return filters[self.list[0]]
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user