Skip to content

Commit 7fd67ee

Browse files
author
Johannes Gijsbers
committed
Change indexer_common.search() to take a list of nodeids...
...instead of a dictionary (with random keys) from getHits(). This removes another Python 2.1 incompatility (using dict() and enumerate()) and removes the need for some code in indexer_rdbms.find().
1 parent 59d1ed1 commit 7fd67ee

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

roundup/backends/back_tsearch2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ def find(self, search_terms, klass):
9898
if not search_terms:
9999
return None
100100

101-
nodeids = self.tsearchQuery(klass.classname, search_terms)
101+
hits = self.tsearchQuery(klass.classname, search_terms)
102102
designator_propname = {}
103103

104104
for nm, propclass in klass.getprops().items():
105105
if _isLink(propclass):
106-
nodeids.extend(self.tsearchQuery(propclass.classname, search_terms))
106+
hits.extend(self.tsearchQuery(propclass.classname, search_terms))
107107

108-
return dict(enumerate(nodeids))
108+
return hits
109109

110110
def tsearchQuery(self, classname, search_terms):
111111
query = """SELECT id FROM _%(classname)s

roundup/backends/indexer_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def search(self, search_terms, klass, ignore={}):
3232
propspec = {} # used to do the klass.find
3333
for propname in designator_propname.values():
3434
propspec[propname] = {} # used as a set (value doesn't matter)
35-
for classname, nodeid, property in hits.values():
35+
for classname, nodeid, property in hits:
3636
# skip this result if we don't care about this class/property
3737
if ignore.has_key((classname, property)):
3838
continue

roundup/backends/indexer_dbm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# that promote freedom, but obviously am giving up any rights
1515
# to compel such.
1616
#
17-
#$Id: indexer_dbm.py,v 1.3 2005-01-04 16:48:46 jlgijsbers Exp $
17+
#$Id: indexer_dbm.py,v 1.4 2005-01-05 22:14:21 jlgijsbers Exp $
1818
'''This module provides an indexer class, RoundupIndexer, that stores text
1919
indices in a roundup instance. This class makes searching the content of
2020
messages, string properties and text files possible.
@@ -184,7 +184,7 @@ def find(self, wordlist):
184184
del hits[fileid]
185185
if hits is None:
186186
return {}
187-
return hits
187+
return hits.values()
188188

189189
segments = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#_-!"
190190
def load_index(self, reload=0, wordlist=None):

roundup/backends/indexer_rdbms.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,7 @@ def find(self, wordlist):
126126

127127
self.db.cursor.execute(sql, tuple(map(int, r)))
128128

129-
# self.search_index has the results as {some id: identifier} ...
130-
# sigh
131-
r = {}
132-
k = 0
133-
for c,n,p in self.db.cursor.fetchall():
134-
key = (str(c), str(n), str(p))
135-
r[k] = key
136-
k += 1
137-
return r
129+
return self.db.cursor.fetchall()
138130

139131
def save_index(self):
140132
# the normal RDBMS backend transaction mechanisms will handle this

0 commit comments

Comments
 (0)