changeset 2505:bdd112cf61ba

rdbms backend full text search failure after import [SF#980314]
author Richard Jones <richard@users.sourceforge.net>
date Mon, 28 Jun 2004 23:13:06 +0000
parents d084aea1910f
children 932ffd8dd631
files CHANGES.txt doc/index.txt roundup/backends/back_anydbm.py roundup/backends/back_metakit.py roundup/backends/rdbms_common.py test/db_test_base.py
diffstat 6 files changed, 59 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Fri Jun 25 22:23:36 2004 +0000
+++ b/CHANGES.txt	Mon Jun 28 23:13:06 2004 +0000
@@ -17,6 +17,11 @@
 
 2004-??-?? 0.7.5
 Fixed:
+- rdbms backend full text search failure after import (sf bug 980314)
+
+
+2004-06-24 0.7.5
+Fixed:
 - force lookup of journal props in anydbm filtering
 - fixed lookup of "missing" Link values for new props in anydbm backend
 - allow list of values for id, Number and Boolean filtering in anydbm
--- a/doc/index.txt	Fri Jun 25 22:23:36 2004 +0000
+++ b/doc/index.txt	Mon Jun 28 23:13:06 2004 +0000
@@ -90,6 +90,7 @@
 Dan Grassi,
 Engelbert Gruber,
 Juergen Hermann,
+Uwe Hoffmann,
 Tobias Hunger,
 Simon Hyde,
 Christophe Kalt,
--- a/roundup/backends/back_anydbm.py	Fri Jun 25 22:23:36 2004 +0000
+++ b/roundup/backends/back_anydbm.py	Mon Jun 28 23:13:06 2004 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.157 2004-06-24 06:39:07 richard Exp $
+#$Id: back_anydbm.py,v 1.158 2004-06-28 23:13:05 richard Exp $
 '''This module defines a backend that saves the hyperdatabase in a
 database chosen by anydbm. It is guaranteed to always be available in python
 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -2166,15 +2166,29 @@
         return propvalues
 
     def getprops(self, protected=1):
-        ''' In addition to the actual properties on the node, these methods
-            provide the "content" property. If the "protected" flag is true,
-            we include protected properties - those which may not be
-            modified.
+        '''In addition to the actual properties on the node, these methods
+        provide the "content" property. If the "protected" flag is true,
+        we include protected properties - those which may not be
+        modified.
+
+        Note that the content prop is indexed separately, hence no indexme.
         '''
         d = Class.getprops(self, protected=protected).copy()
         d['content'] = hyperdb.String()
         return d
 
+    def index(self, nodeid):
+        '''Add (or refresh) the node to search indexes.
+
+        Pass on the content-type property for the content property.
+        '''
+        Class.index(self, nodeid)
+        mimetype = self.get(nodeid, 'type')
+        if not mimetype:
+            mimetype = self.default_mime_type
+        self.db.indexer.add_text((self.classname, nodeid, 'content'),
+                    self.get(nodeid, 'content'), mimetype)
+
 # deviation from spec - was called ItemClass
 class IssueClass(Class, roundupdb.IssueClass):
     # Overridden methods:
--- a/roundup/backends/back_metakit.py	Fri Jun 25 22:23:36 2004 +0000
+++ b/roundup/backends/back_metakit.py	Mon Jun 28 23:13:06 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: back_metakit.py,v 1.76 2004-06-24 09:57:49 richard Exp $
+# $Id: back_metakit.py,v 1.77 2004-06-28 23:13:05 richard Exp $
 '''Metakit backend for Roundup, originally by Gordon McMillan.
 
 Known Current Bugs:
@@ -1946,6 +1946,10 @@
         self.fireReactors('set', oldnode, propvalues)
 
     def index(self, nodeid):
+        '''Add (or refresh) the node to search indexes.
+
+        Pass on the content-type property for the content property.
+        '''
         Class.index(self, nodeid)
         mimetype = self.get(nodeid, 'type')
         if not mimetype:
--- a/roundup/backends/rdbms_common.py	Fri Jun 25 22:23:36 2004 +0000
+++ b/roundup/backends/rdbms_common.py	Mon Jun 28 23:13:06 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.112 2004-06-24 06:39:07 richard Exp $
+# $Id: rdbms_common.py,v 1.113 2004-06-28 23:13:05 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -2426,7 +2426,10 @@
         # make the new node's property map
         d = {}
         retire = 0
-        newid = None
+        if not "id" in propnames:
+            newid = self.db.newid(self.classname)
+        else:
+            newid = eval(proplist[propnames.index("id")])
         for i in range(len(propnames)):
             # Use eval to reverse the repr() used to output the CSV
             value = eval(proplist[i])
@@ -2436,7 +2439,6 @@
 
             # "unmarshal" where necessary
             if propname == 'id':
-                newid = value
                 continue
             elif propname == 'is retired':
                 # is the item retired?
@@ -2460,6 +2462,11 @@
                 pwd.unpack(value)
                 value = pwd
             d[propname] = value
+            if isinstance(prop, String) and prop.indexme:
+                if type(value) != type('') and type(value) != type(u''):
+                    raise TypeError, 'new property "%s" not a string'%key
+                self.db.indexer.add_text((self.classname, newid, propname),
+                    value)
 
         # get a new id if necessary
         if newid is None:
@@ -2600,10 +2607,12 @@
             return Class.get(self, nodeid, propname)
 
     def getprops(self, protected=1):
-        ''' In addition to the actual properties on the node, these methods
-            provide the "content" property. If the "protected" flag is true,
-            we include protected properties - those which may not be
-            modified.
+        '''In addition to the actual properties on the node, these methods
+        provide the "content" property. If the "protected" flag is true,
+        we include protected properties - those which may not be
+        modified.
+
+        Note that the content prop is indexed separately, hence no indexme.
         '''
         d = Class.getprops(self, protected=protected).copy()
         d['content'] = hyperdb.String()
@@ -2638,6 +2647,18 @@
         self.fireReactors('set', itemid, oldvalues)
         return propvalues
 
+    def index(self, nodeid):
+        '''Add (or refresh) the node to search indexes.
+
+        Pass on the content-type property for the content property.
+        '''
+        Class.index(nodeid)
+        mime_type = self.get(itemid, 'type')
+        if not mime_type:
+            mime_type = self.default_mime_type
+        self.db.indexer.add_text((self.classname, nodeid, 'content'),
+            str(self.get(nodeid, 'content')), mime_type)
+
 # XXX deviation from spec - was called ItemClass
 class IssueClass(Class, roundupdb.IssueClass):
     # Overridden methods:
--- a/test/db_test_base.py	Fri Jun 25 22:23:36 2004 +0000
+++ b/test/db_test_base.py	Mon Jun 28 23:13:06 2004 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: db_test_base.py,v 1.34 2004-06-24 06:39:07 richard Exp $ 
+# $Id: db_test_base.py,v 1.35 2004-06-28 23:13:06 richard Exp $ 
 
 import unittest, os, shutil, errno, imp, sys, time, pprint
 
@@ -703,7 +703,6 @@
         self.assertEquals(self.db.indexer.search(['hello'], self.db.issue),
             {i1: {'files': [f2]}})
 
-
     def testForcedReindexing(self):
         self.db.issue.create(title="flebble frooz")
         self.db.commit()

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