changeset 2453:0e2a0c2c8142

allow list of values for id, Number and Boolean filtering in anydbm backend
author Richard Jones <richard@users.sourceforge.net>
date Sun, 13 Jun 2004 01:05:46 +0000
parents c45ed2413044
children ece6ed48dd3d
files CHANGES.txt doc/index.txt roundup/backends/back_anydbm.py test/db_test_base.py
diffstat 4 files changed, 26 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Sun Jun 13 00:27:45 2004 +0000
+++ b/CHANGES.txt	Sun Jun 13 01:05:46 2004 +0000
@@ -15,6 +15,8 @@
 Fixed:
 - force lookup of journal props in anydbm filtering
 - fixed lookup of "missing" Link values for new props in anydbm backend
+- allow list of values for id, Number and Boolean filtering in anydbm
+  backend
 
 
 2004-06-10 0.7.4
--- a/doc/index.txt	Sun Jun 13 00:27:45 2004 +0000
+++ b/doc/index.txt	Sun Jun 13 01:05:46 2004 +0000
@@ -89,6 +89,7 @@
 Engelbert Gruber,
 Juergen Hermann,
 Tobias Hunger,
+Simon Hyde,
 Christophe Kalt,
 Brian Kelley,
 James Kew,
--- a/roundup/backends/back_anydbm.py	Sun Jun 13 00:27:45 2004 +0000
+++ b/roundup/backends/back_anydbm.py	Sun Jun 13 01:05:46 2004 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.154 2004-06-13 00:27:45 richard Exp $
+#$Id: back_anydbm.py,v 1.155 2004-06-13 01:05:46 richard Exp $
 '''This module defines a backend that saves the hyperdatabase in a
 database chosen by anydbm. It is guaranteed to always be available in python
 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1654,15 +1654,26 @@
                     pass
                 
             elif isinstance(propclass, Boolean):
-                if type(v) is type(''):
-                    bv = v.lower() in ('yes', 'true', 'on', '1')
-                else:
-                    bv = v
+                if type(v) != type([]):
+                    v = v.split(',')
+                bv = []
+                for val in v:
+                    if type(val) is type(''):
+                        bv.append(val.lower() in ('yes', 'true', 'on', '1'))
+                    else:
+                        bv.append(val)
                 l.append((OTHER, k, bv))
+
+            elif k == 'id':
+                if type(v) != type([]):
+                    v = v.split(',')
+                l.append((OTHER, k, [str(int(val)) for val in v]))
+
             elif isinstance(propclass, Number):
-                l.append((OTHER, k, float(v)))
-            else:
-                l.append((OTHER, k, v))
+                if type(v) != type([]):
+                    v = v.split(',')
+                l.append((OTHER, k, [float(val) for val in v]))
+
         filterspec = l
 
         # now, find all the nodes that are active and pass filtering
@@ -1678,7 +1689,7 @@
                 # apply filter
                 for t, k, v in filterspec:
                     # handle the id prop
-                    if k == 'id' and v == nodeid:
+                    if k == 'id' and nodeid in v:
                         continue
 
                     # make sure the node has the property
@@ -1726,7 +1737,7 @@
                                 break
                     elif t == OTHER:
                         # straight value comparison for the other types
-                        if node[k] != v:
+                        if node[k] not in v:
                             break
                 else:
                     matches.append([nodeid, node])
--- a/test/db_test_base.py	Sun Jun 13 00:27:45 2004 +0000
+++ b/test/db_test_base.py	Sun Jun 13 01:05:46 2004 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: db_test_base.py,v 1.30 2004-06-09 06:35:45 richard Exp $ 
+# $Id: db_test_base.py,v 1.31 2004-06-13 01:05:46 richard Exp $ 
 
 import unittest, os, shutil, errno, imp, sys, time, pprint
 
@@ -846,6 +846,7 @@
         ae(filt(None, {'age': '1'}, ('+','id'), (None,None)), ['3'])
         ae(filt(None, {'age': '1.5'}, ('+','id'), (None,None)), ['4'])
         ae(filt(None, {'age': '2'}, ('+','id'), (None,None)), ['5'])
+        ae(filt(None, {'age': ['1','2']}, ('+','id'), (None,None)), ['3','5'])
 
     def testFilteringString(self):
         ae, filt = self.filteringSetup()

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