Skip to content

Commit 059d833

Browse files
author
Richard Jones
committed
API clarification.
Previously, the anydbm/bsddb/metakit filter() methods had required exact matches to Multilink argument lists. The RDBMS backends treated Multilink matches like all other data types - matching any of the Multilink argument list is good enough. The latter behaviour is implemented across the board now.
1 parent a8acbbb commit 059d833

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Fixed:
3333
- document the STATIC_FILES config var
3434
- implement the HTTP HEAD command (sf bug 992544)
3535
- fix journal export of files to remove content from CSV files
36+
- API clarification. Previously, the anydbm/bsddb/metakit filter() methods
37+
had required exact matches to Multilink argument lists. The RDBMS
38+
backends treated Multilink matches like all other data types - matching
39+
any of the Multilink argument list is good enough. The latter behaviour
40+
is implemented across the board now.
3641

3742

3843
2004-06-24 0.7.5

roundup/backends/back_anydbm.py

Lines changed: 4 additions & 7 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.162 2004-07-20 07:26:40 richard Exp $
18+
#$Id: back_anydbm.py,v 1.163 2004-07-20 22:56:18 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
@@ -1536,9 +1536,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
15361536
15371537
The filter must match all properties specificed - but if the
15381538
property value to match is a list, any one of the values in the
1539-
list may match for that property to match. Unless the property
1540-
is a Multilink, in which case the item's property list must
1541-
match the filterspec list.
1539+
list may match for that property to match.
15421540
"""
15431541
if __debug__:
15441542
start_t = time.time()
@@ -1666,10 +1664,9 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16661664
# othewise, make sure this node has each of the
16671665
# required values
16681666
for want in v:
1669-
if want not in nv:
1667+
if want in nv:
1668+
match = True
16701669
break
1671-
else:
1672-
match = True
16731670
elif t == STRING:
16741671
if nv is None:
16751672
nv = ''

roundup/backends/back_metakit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.79 2004-07-20 05:58:07 richard Exp $
1+
# $Id: back_metakit.py,v 1.80 2004-07-20 22:56:18 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -1313,12 +1313,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
13131313
def ff(row, ml=mlcriteria):
13141314
for propname, values in ml.items():
13151315
sv = getattr(row, propname)
1316-
if not values and sv:
1317-
return 0
1316+
if not values and not sv:
1317+
return 1
13181318
for id in values:
1319-
if sv.find(fid=id) == -1:
1320-
return 0
1321-
return 1
1319+
if sv.find(fid=id) != -1:
1320+
return 1
1321+
return 0
13221322
iv = v.filter(ff)
13231323
v = v.remapwith(iv)
13241324

test/db_test_base.py

Lines changed: 4 additions & 3 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: db_test_base.py,v 1.39 2004-07-03 23:05:15 richard Exp $
18+
# $Id: db_test_base.py,v 1.40 2004-07-20 22:56:18 richard Exp $
1919

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

@@ -693,6 +693,7 @@ def testFileClassReindexing(self):
693693
i1 = self.db.issue.create(files=[f1, f2])
694694
self.db.commit()
695695
d = self.db.indexer.search(['hello'], self.db.issue)
696+
self.assert_(d.has_key(i1))
696697
d[i1]['files'].sort()
697698
self.assertEquals(d, {i1: {'files': [f1, f2]}})
698699
self.assertEquals(self.db.indexer.search(['world'], self.db.issue),
@@ -841,7 +842,7 @@ def filteringSetup(self):
841842
{'title': 'issue two', 'status': '1', 'assignedto': '2',
842843
'foo': date.Interval('1d'), 'priority': '3',
843844
'deadline': date.Date('2003-02-16.22:50')},
844-
{'title': 'issue three', 'status': '1', 'priority': '2',
845+
{'title': 'issue three', 'status': '1', 'priority': '2',
845846
'nosy': ['1','2'], 'deadline': date.Date('2003-02-18')},
846847
{'title': 'non four', 'status': '3',
847848
'foo': date.Interval('0:10'), 'priority': '2',
@@ -894,7 +895,7 @@ def testFilteringMultilink(self):
894895
ae(filt(None, {'nosy': '2'}, ('+','id'), (None,None)), ['3'])
895896
ae(filt(None, {'nosy': '-1'}, ('+','id'), (None,None)), ['1', '2'])
896897
ae(filt(None, {'nosy': ['1','2']}, ('+', 'status'),
897-
('-', 'activity')), ['4', '3'])
898+
('-', 'deadline')), ['4', '3'])
898899

899900
def testFilteringMany(self):
900901
ae, filt = self.filteringSetup()

0 commit comments

Comments
 (0)