* src/GenericFilter.py: Call prepare/reset for nested filters
svn: r4319
This commit is contained in:
parent
0c112b11eb
commit
89c75e626f
@ -1,3 +1,6 @@
|
|||||||
|
2005-04-07 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||||
|
* src/GenericFilter.py: Call prepare/reset for nested filters
|
||||||
|
|
||||||
2005-04-07 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
2005-04-07 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
* src/gramps_main.py: correct type signature for 'active-changed' signal.
|
* src/gramps_main.py: correct type signature for 'active-changed' signal.
|
||||||
* src/GrampsDBCallback.py: improve the error reporting.
|
* src/GrampsDBCallback.py: improve the error reporting.
|
||||||
|
@ -570,9 +570,11 @@ class IsChildOfFilterMatch(Rule):
|
|||||||
self.db = db
|
self.db = db
|
||||||
self.map = {}
|
self.map = {}
|
||||||
filt = MatchesFilter(self.list)
|
filt = MatchesFilter(self.list)
|
||||||
|
filt.prepare(db)
|
||||||
for person_handle in db.get_person_handles(sort_handles=False):
|
for person_handle in db.get_person_handles(sort_handles=False):
|
||||||
if filt.apply (db, person_handle):
|
if filt.apply (db, person_handle):
|
||||||
self.init_list (person_handle)
|
self.init_list (person_handle)
|
||||||
|
filt.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.map = {}
|
self.map = {}
|
||||||
@ -611,9 +613,11 @@ class IsSiblingOfFilterMatch(Rule):
|
|||||||
self.db = db
|
self.db = db
|
||||||
self.map = {}
|
self.map = {}
|
||||||
filt = MatchesFilter(self.list)
|
filt = MatchesFilter(self.list)
|
||||||
|
filt.prepare(db)
|
||||||
for person_handle in db.get_person_handles(sort_handles=False):
|
for person_handle in db.get_person_handles(sort_handles=False):
|
||||||
if filt.apply (db, person_handle):
|
if filt.apply (db, person_handle):
|
||||||
self.init_list (person_handle)
|
self.init_list (person_handle)
|
||||||
|
filt.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.map = {}
|
self.map = {}
|
||||||
@ -769,9 +773,11 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
|
|||||||
|
|
||||||
self.init = 1
|
self.init = 1
|
||||||
filt = MatchesFilter(self.list)
|
filt = MatchesFilter(self.list)
|
||||||
|
filt.prepare(db)
|
||||||
for person_handle in db.get_person_handles(sort_handles=False):
|
for person_handle in db.get_person_handles(sort_handles=False):
|
||||||
if filt.apply (db, person_handle):
|
if filt.apply (db, person_handle):
|
||||||
self.init_ancestor_list (db,person_handle,first)
|
self.init_ancestor_list (db,person_handle,first)
|
||||||
|
filt.reset()
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return 'Is an ancestor of filter match'
|
return 'Is an ancestor of filter match'
|
||||||
@ -910,9 +916,11 @@ class IsParentOfFilterMatch(Rule):
|
|||||||
self.db = db
|
self.db = db
|
||||||
self.map = {}
|
self.map = {}
|
||||||
filt = MatchesFilter(self.list)
|
filt = MatchesFilter(self.list)
|
||||||
|
filt.prepare(db)
|
||||||
for person_handle in db.get_person_handles(sort_handles=False):
|
for person_handle in db.get_person_handles(sort_handles=False):
|
||||||
if filt.apply (db, person_handle):
|
if filt.apply (db, person_handle):
|
||||||
self.init_list (person_handle)
|
self.init_list (person_handle)
|
||||||
|
filt.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.map = {}
|
self.map = {}
|
||||||
@ -1011,11 +1019,13 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith):
|
|||||||
|
|
||||||
def init_ancestor_cache(self,db):
|
def init_ancestor_cache(self,db):
|
||||||
filt = MatchesFilter(self.list)
|
filt = MatchesFilter(self.list)
|
||||||
|
filt.prepare(db)
|
||||||
def init(self,pid): self.ancestor_cache[pid] = 1
|
def init(self,pid): self.ancestor_cache[pid] = 1
|
||||||
for p_id in db.get_person_handles(sort_handles=False):
|
for p_id in db.get_person_handles(sort_handles=False):
|
||||||
if (not self.ancestor_cache.has_key (p_id)
|
if (not self.ancestor_cache.has_key (p_id)
|
||||||
and filt.apply (db, p_id)):
|
and filt.apply (db, p_id)):
|
||||||
for_each_ancestor(db,[p_id],init,self)
|
for_each_ancestor(db,[p_id],init,self)
|
||||||
|
filt.reset()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -1449,6 +1459,26 @@ class MatchesFilter(Rule):
|
|||||||
|
|
||||||
labels = [_('Filter name:')]
|
labels = [_('Filter name:')]
|
||||||
|
|
||||||
|
def prepare(self,db):
|
||||||
|
for filt in SystemFilters.get_filters():
|
||||||
|
if filt.get_name() == self.list[0]:
|
||||||
|
for rule in filt.flist:
|
||||||
|
rule.prepare(db)
|
||||||
|
for filt in CustomFilters.get_filters():
|
||||||
|
if filt.get_name() == self.list[0]:
|
||||||
|
for rule in filt.flist:
|
||||||
|
rule.prepare(db)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
for filt in SystemFilters.get_filters():
|
||||||
|
if filt.get_name() == self.list[0]:
|
||||||
|
for rule in filt.flist:
|
||||||
|
rule.reset()
|
||||||
|
for filt in CustomFilters.get_filters():
|
||||||
|
if filt.get_name() == self.list[0]:
|
||||||
|
for rule in filt.flist:
|
||||||
|
rule.reset()
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return 'Matches the filter named'
|
return 'Matches the filter named'
|
||||||
|
|
||||||
@ -2002,7 +2032,7 @@ class HasSourceOf(Rule):
|
|||||||
return _('Matches people who have a particular source')
|
return _('Matches people who have a particular source')
|
||||||
|
|
||||||
def apply(self,db,p_id):
|
def apply(self,db,p_id):
|
||||||
p = self.db.get_person_from_handle(p_id)
|
p = db.get_person_from_handle(p_id)
|
||||||
|
|
||||||
return p.has_source_reference( self.source_handle)
|
return p.has_source_reference( self.source_handle)
|
||||||
|
|
||||||
@ -2329,9 +2359,14 @@ class ParamFilter(GenericFilter):
|
|||||||
self.param_list = [param]
|
self.param_list = [param]
|
||||||
|
|
||||||
def apply(self,db,id_list):
|
def apply(self,db,id_list):
|
||||||
|
for rule in self.flist:
|
||||||
|
rule.prepare(db)
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
rule.set_list(self.param_list)
|
rule.set_list(self.param_list)
|
||||||
return GenericFilter.apply(self,db,id_list)
|
result = GenericFilter.apply(self,db,id_list)
|
||||||
|
for rule in self.flist:
|
||||||
|
rule.reset()
|
||||||
|
return result
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user