Skip to content

Commit 57b1108

Browse files
author
Richard Jones
committed
fix SearchAction use of Class.filter(), and clarify API docs for same
1 parent da84fde commit 57b1108

File tree

6 files changed

+18
-21
lines changed

6 files changed

+18
-21
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Feature:
1212
Fixed:
1313
- add "checked" to truth values for Boolean input
1414
- fixed import in metakit backend
15+
- fix SearchAction use of Class.filter(), and clarify API docs for same
1516

1617

1718
2004-05-?? 0.7.2

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 2 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.148 2004-05-16 09:35:49 richard Exp $
18+
#$Id: back_anydbm.py,v 1.149 2004-05-23 23:24:47 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
@@ -1579,7 +1579,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
15791579
"sort" and "group" are (dir, prop) where dir is '+', '-' or None
15801580
and prop is a prop name or None
15811581
1582-
"search_matches" is {nodeid: marker}
1582+
"search_matches" is {nodeid: marker} or None
15831583
15841584
The filter must match all properties specificed - but if the
15851585
property value to match is a list, any one of the values in the

roundup/backends/back_metakit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.71 2004-05-18 15:17:19 wc2so1 Exp $
1+
# $Id: back_metakit.py,v 1.72 2004-05-23 23:24:47 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -1174,7 +1174,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
11741174
"sort" and "group" are (dir, prop) where dir is '+', '-' or None
11751175
and prop is a prop name or None
11761176
1177-
"search_matches" is {nodeid: marker}
1177+
"search_matches" is {nodeid: marker} or None
11781178
11791179
The filter must match all properties specificed - but if the
11801180
property value to match is a list, any one of the values in the

roundup/backends/back_mysql.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
499499
"sort" and "group" are (dir, prop) where dir is '+', '-' or None
500500
and prop is a prop name or None
501501
502-
"search_matches" is {nodeid: marker}
502+
"search_matches" is {nodeid: marker} or None
503503
504504
The filter must match all properties specificed - but if the
505505
property value to match is a list, any one of the values in the
506506
list may match for that property to match.
507507
'''
508-
# just don't bother if the full-text search matched diddly
509-
if search_matches == {}:
510-
return []
511-
512508
if __debug__:
513509
start_t = time.time()
514510

roundup/backends/rdbms_common.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.101 2004-05-16 21:49:30 richard Exp $
1+
# $Id: rdbms_common.py,v 1.102 2004-05-23 23:24:47 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1991,16 +1991,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
19911991
"sort" and "group" are (dir, prop) where dir is '+', '-' or None
19921992
and prop is a prop name or None
19931993
1994-
"search_matches" is {nodeid: marker}
1994+
"search_matches" is {nodeid: marker} or None
19951995
19961996
The filter must match all properties specificed - but if the
19971997
property value to match is a list, any one of the values in the
19981998
list may match for that property to match.
19991999
'''
2000-
# just don't bother if the full-text search matched diddly
2001-
if search_matches == {}:
2002-
return []
2003-
20042000
if __debug__:
20052001
start_t = time.time()
20062002

@@ -2198,6 +2194,8 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21982194
# psycopg doesn't like empty args
21992195
self.db.cursor.execute(sql)
22002196
l = self.db.sql_fetchall()
2197+
if __debug__:
2198+
print >>hyperdb.DEBUG, '... matched', len(l)
22012199

22022200
# return the IDs (the first column)
22032201
# XXX numeric ids

roundup/cgi/actions.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.28 2004-05-13 00:19:35 richard Exp $
1+
#$Id: actions.py,v 1.29 2004-05-23 23:24:47 richard Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random
44

@@ -148,18 +148,20 @@ def handle(self, wcre=re.compile(r'[\s,]+')):
148148
# edit the new way, query name not a key any more
149149
# see if we match an existing private query
150150
uid = self.db.getuid()
151-
qids = self.db.query.filter({}, {'name': queryname,
151+
qids = self.db.query.filter(None, {'name': queryname,
152152
'private_for': uid})
153153
if not qids:
154154
# ok, so there's not a private query for the current user
155155
# - see if there's a public one created by them
156-
qids = self.db.query.filter({}, {'name': queryname,
156+
qids = self.db.query.filter(None, {'name': queryname,
157157
'private_for': -1, 'creator': uid})
158158

159159
if qids:
160-
# edit query
161-
qid = qids[0]
162-
self.db.query.set(qid, klass=self.classname, url=url)
160+
# edit query - make sure we get an exact match on the name
161+
for qid in qids:
162+
if queryname != self.db.query.get(qid, 'name'):
163+
continue
164+
self.db.query.set(qid, klass=self.classname, url=url)
163165
else:
164166
# create a query
165167
qid = self.db.query.create(name=queryname,

0 commit comments

Comments
 (0)