diff roundup/roundup_indexer.py @ 692:0521ddc7bb31 search_indexing-0-4-2-branch

Miscellaneous changes. cgi_client.py removed search link for the time being moved rendering of matches to htmltemplate hyperdb.py filtering of nodes on full text search incorporated in filter method roundupdb.py added paramater to call of filter method roundup_indexer.py added search method to RoundupIndexer class
author Roche Compaan <rochecompaan@users.sourceforge.net>
date Fri, 19 Apr 2002 19:54:42 +0000
parents 1b2d0e702ca8
children 8d2cb0d09da4
line wrap: on
line diff
--- a/roundup/roundup_indexer.py	Mon Apr 15 23:25:16 2002 +0000
+++ b/roundup/roundup_indexer.py	Fri Apr 19 19:54:42 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: roundup_indexer.py,v 1.1.2.1 2002-04-03 11:55:57 rochecompaan Exp $
+#$Id: roundup_indexer.py,v 1.1.2.2 2002-04-19 19:54:42 rochecompaan Exp $
 '''
 This module provides an indexer class, RoundupIndexer, that stores text
 indices in a roundup instance.  This class makes searching the content of
@@ -43,5 +43,41 @@
             self.add_files(dir=files_path)
             self.save_index()
 
+    def search(self, search_terms, klass):
+        ''' display search results
+        '''
+        hits = self.find(search_terms)
+        links = []
+        nodeids = {}
+        designator_propname = {'msg': 'messages',
+                               'file': 'files'}
+        if hits:
+            hitcount = len(hits)
+            # build a dictionary of nodes and their associated messages
+            # and files
+            for hit in hits.keys():
+                filename = hits[hit].split('/')[-1]
+                for designator, propname in designator_propname.items():
+                    if filename.find(designator) == -1: continue
+                    nodeid = filename[len(designator):]
+                    result = apply(klass.find, (), {propname:nodeid})
+                    if not result: continue
+
+                    id = str(result[0])
+                    if not nodeids.has_key(id):
+                        nodeids[id] = {}
+
+                    node_dict = nodeids[id]
+                    if not node_dict.has_key(propname):
+                        node_dict[propname] = [nodeid]
+                    elif node_dict.has_key(propname):
+                        node_dict[propname].append(nodeid)
+
+        return nodeids
+
+
 #
 #$Log: not supported by cvs2svn $
+#Revision 1.1.2.1  2002/04/03 11:55:57  rochecompaan
+# . Added feature #526730 - search for messages capability
+#

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