diff roundup/backends/back_anydbm.py @ 5318:506c7ee9a385

Add a 'retired' parameter to Class.filter .. to allow searching for retired, non-retired or all (retired and non-retired) items similar to the argument of the same name to Class.getnodeids. This is 'False' by default (finding only non-retired items for backwards compatibility) and can be set to None (for finding retired and non-retired items) or True (for finding only retired items).
author Ralf Schlatterbeck <rsc@runtux.com>
date Thu, 19 Apr 2018 20:01:43 +0200
parents 198b6e810c67
children 62de601bdf6f
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Thu Apr 19 17:03:11 2018 +0200
+++ b/roundup/backends/back_anydbm.py	Thu Apr 19 20:01:43 2018 +0200
@@ -1683,8 +1683,8 @@
         return res
 
     def _filter(self, search_matches, filterspec, proptree,
-            num_re = re.compile('^\d+$')):
-        """Return a list of the ids of the active nodes in this class that
+            num_re = re.compile('^\d+$'), retired=False):
+        """Return a list of the ids of the nodes in this class that
         match the 'filter' spec, sorted by the group spec and then the
         sort spec.
 
@@ -1695,6 +1695,9 @@
 
         "search_matches" is a sequence type or None
 
+        "retired" specifies if we should find only non-retired nodes
+        (default) or only retired node (value True) or all nodes.
+
         The filter must match all properties specificed. If the property
         value to match is a list:
 
@@ -1795,16 +1798,14 @@
 
         filterspec = l
 
-        # now, find all the nodes that are active and pass filtering
+        # now, find all the nodes that pass filtering
         matches = []
         cldb = self.db.getclassdb(cn)
         t = 0
         try:
             # TODO: only full-scan once (use items())
-            for nodeid in self.getnodeids(cldb):
+            for nodeid in self.getnodeids(cldb, retired=retired):
                 node = self.db.getnode(cn, nodeid, cldb)
-                if self.db.RETIRED_FLAG in node:
-                    continue
                 # apply filter
                 for t, k, v in filterspec:
                     # handle the id prop

Roundup Issue Tracker: http://roundup-tracker.org/