@@ -2381,7 +2381,8 @@ def collect_values(n): values.append(n.x)
23812381 multilink_table , ',' .join ([self .db .arg ] * len (v )))
23822382 return where , v , True # True to indicate original
23832383
2384- def _filter_sql (self , search_matches , filterspec , srt = [], grp = [], retr = 0 ):
2384+ def _filter_sql (self , search_matches , filterspec , srt = [], grp = [], retr = 0 ,
2385+ retired = False ):
23852386 """ Compute the proptree and the SQL/ARGS for a filter.
23862387 For argument description see filter below.
23872388 We return a 3-tuple, the proptree, the sql and the sql-args
@@ -2650,7 +2651,11 @@ def _filter_sql (self, search_matches, filterspec, srt=[], grp=[], retr=0):
26502651 props = self .getprops ()
26512652
26522653 # don't match retired nodes
2653- where .append ('_%s.__retired__=0' % icn )
2654+ if retired is not None :
2655+ op = '='
2656+ if retired :
2657+ op = '!='
2658+ where .append ('_%s.__retired__%s0' % (icn , op ))
26542659
26552660 # add results of full text search
26562661 if search_matches is not None :
@@ -2688,7 +2693,8 @@ def _filter_sql (self, search_matches, filterspec, srt=[], grp=[], retr=0):
26882693 __traceback_info__ = (sql , args )
26892694 return proptree , sql , args
26902695
2691- def filter (self , search_matches , filterspec , sort = [], group = []):
2696+ def filter (self , search_matches , filterspec , sort = [], group = [],
2697+ retired = False ):
26922698 """Return a list of the ids of the active nodes in this class that
26932699 match the 'filter' spec, sorted by the group spec and then the
26942700 sort spec
@@ -2711,7 +2717,8 @@ def filter(self, search_matches, filterspec, sort=[], group=[]):
27112717 if __debug__ :
27122718 start_t = time .time ()
27132719
2714- sq = self ._filter_sql (search_matches , filterspec , sort , group )
2720+ sq = self ._filter_sql (search_matches , filterspec , sort , group ,
2721+ retired = retired )
27152722 # nothing to match?
27162723 if sq is None :
27172724 return []
@@ -2734,7 +2741,8 @@ def filter(self, search_matches, filterspec, sort=[], group=[]):
27342741 self .db .stats ['filtering' ] += (time .time () - start_t )
27352742 return l
27362743
2737- def filter_iter (self , search_matches , filterspec , sort = [], group = []):
2744+ def filter_iter (self , search_matches , filterspec , sort = [], group = [],
2745+ retired = False ):
27382746 """Iterator similar to filter above with same args.
27392747 Limitation: We don't sort on multilinks.
27402748 This uses an optimisation: We put all nodes that are in the
@@ -2743,7 +2751,8 @@ def filter_iter(self, search_matches, filterspec, sort=[], group=[]):
27432751 a join) from the database because the nodes are already in the
27442752 cache. We're using our own temporary cursor.
27452753 """
2746- sq = self ._filter_sql (search_matches , filterspec , sort , group , retr = 1 )
2754+ sq = self ._filter_sql (search_matches , filterspec , sort , group , retr = 1 ,
2755+ retired = retired )
27472756 # nothing to match?
27482757 if sq is None :
27492758 return
0 commit comments