diff roundup/backends/back_metakit.py @ 3095:a588dab13664

Update metakit indexer: * Derive from indexer_common instead of indexer_dbm. * Use is_stopword instead of self.disallows. * Return a list of nodeids from find() instead of a dictionary.
author Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
date Sun, 09 Jan 2005 19:01:09 +0000
parents 574525e4936b
children dbf80d7db63f
line wrap: on
line diff
--- a/roundup/backends/back_metakit.py	Sun Jan 09 05:34:54 2005 +0000
+++ b/roundup/backends/back_metakit.py	Sun Jan 09 19:01:09 2005 +0000
@@ -1,4 +1,4 @@
-# $Id: back_metakit.py,v 1.88 2004-10-24 10:44:49 a1s Exp $
+# $Id: back_metakit.py,v 1.89 2005-01-09 19:01:09 jlgijsbers Exp $
 '''Metakit backend for Roundup, originally by Gordon McMillan.
 
 Known Current Bugs:
@@ -45,7 +45,7 @@
 import metakit
 from sessions_dbm import Sessions, OneTimeKeys
 import re, marshal, os, sys, time, calendar, shutil
-from indexer_dbm import Indexer
+from indexer_common import Indexer, is_stopword
 import locking
 from roundup.date import Range
 from blobfiles import files_in_dir
@@ -2001,7 +2001,6 @@
 CURVERSION = 2
 
 class Indexer(Indexer):
-    disallows = {'THE':1, 'THIS':1, 'ZZZ':1, 'THAT':1, 'WITH':1}
     def __init__(self, path, datadb):
         self.path = os.path.join(path, 'index.mk4')
         self.db = metakit.storage(self.path, 1)
@@ -2078,7 +2077,7 @@
         wordlist = re.findall(r'\b\w{2,25}\b', text.upper())
         words = {}
         for word in wordlist:
-            if not self.disallows.has_key(word):
+            if not is_stopword(word):
                 words[word] = 1
         words = words.keys()
 
@@ -2112,8 +2111,8 @@
             if len(hits) == 0:
                 return {}
         if hits is None:
-            return {}
-        rslt = {}
+            return []
+        rslt = []
         ids = self.db.view('ids').remapwith(hits)
         tbls = self.datadb.view('tables')
         for i in range(len(ids)):
@@ -2122,7 +2121,7 @@
                 classname = tbls[hit.tblid].name
                 nodeid = str(hit.nodeid)
                 property = self._getpropname(classname, hit.propid)
-                rslt[i] = (classname, nodeid, property)
+                rslt.append((classname, nodeid, property))
         return rslt
 
     def save_index(self):

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