Skip to content

Commit ddb3f41

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent e0a90cc commit ddb3f41

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ are given with the most recent entry first.
55
Fixed:
66
- force lookup of journal props in anydbm filtering
77
- fixed lookup of "missing" Link values for new props in anydbm backend
8+
- allow list of values for id, Number and Boolean filtering in anydbm
9+
backend
810

911

1012
2004-06-10 0.7.4

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Dan Grassi,
8989
Engelbert Gruber,
9090
Juergen Hermann,
9191
Tobias Hunger,
92+
Simon Hyde,
9293
Christophe Kalt,
9394
Brian Kelley,
9495
James Kew,

roundup/backends/back_anydbm.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.146.2.8 2004-06-13 00:40:55 richard Exp $
18+
#$Id: back_anydbm.py,v 1.146.2.9 2004-06-13 01:11:23 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1654,15 +1654,26 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16541654
pass
16551655

16561656
elif isinstance(propclass, Boolean):
1657-
if type(v) is type(''):
1658-
bv = v.lower() in ('yes', 'true', 'on', '1')
1659-
else:
1660-
bv = v
1657+
if type(v) != type([]):
1658+
v = v.split(',')
1659+
bv = []
1660+
for val in v:
1661+
if type(val) is type(''):
1662+
bv.append(val.lower() in ('yes', 'true', 'on', '1'))
1663+
else:
1664+
bv.append(val)
16611665
l.append((OTHER, k, bv))
1666+
1667+
elif k == 'id':
1668+
if type(v) != type([]):
1669+
v = v.split(',')
1670+
l.append((OTHER, k, [str(int(val)) for val in v]))
1671+
16621672
elif isinstance(propclass, Number):
1663-
l.append((OTHER, k, float(v)))
1664-
else:
1665-
l.append((OTHER, k, v))
1673+
if type(v) != type([]):
1674+
v = v.split(',')
1675+
l.append((OTHER, k, [float(val) for val in v]))
1676+
16661677
filterspec = l
16671678

16681679
# now, find all the nodes that are active and pass filtering
@@ -1678,7 +1689,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16781689
# apply filter
16791690
for t, k, v in filterspec:
16801691
# handle the id prop
1681-
if k == 'id' and v == nodeid:
1692+
if k == 'id' and nodeid in v:
16821693
continue
16831694

16841695
# make sure the node has the property
@@ -1726,7 +1737,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
17261737
break
17271738
elif t == OTHER:
17281739
# straight value comparison for the other types
1729-
if node[k] != v:
1740+
if node[k] not in v:
17301741
break
17311742
else:
17321743
matches.append([nodeid, node])

test/db_test_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.27.2.3 2004-06-09 06:37:22 richard Exp $
18+
# $Id: db_test_base.py,v 1.27.2.4 2004-06-13 01:08:06 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -846,6 +846,7 @@ def testFilteringNumber(self):
846846
ae(filt(None, {'age': '1'}, ('+','id'), (None,None)), ['3'])
847847
ae(filt(None, {'age': '1.5'}, ('+','id'), (None,None)), ['4'])
848848
ae(filt(None, {'age': '2'}, ('+','id'), (None,None)), ['5'])
849+
ae(filt(None, {'age': ['1','2']}, ('+','id'), (None,None)), ['3','5'])
849850

850851
def testFilteringString(self):
851852
ae, filt = self.filteringSetup()

0 commit comments

Comments
 (0)