diff roundup/backends/rdbms_common.py @ 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 682eefe8ef23
children 8e1c1623710b
line wrap: on
line diff
--- 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:

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