diff roundup/roundupdb.py @ 825:0779ea9f1f18

More indexer work: - all String properties may now be indexed too. Currently there's a bit of "issue" specific code in the actual searching which needs to be addressed. In a nutshell: + pass 'indexme="yes"' as a String() property initialisation arg, eg: file = FileClass(db, "file", name=String(), type=String(), comment=String(indexme="yes")) + the comment will then be indexed and be searchable, with the results related back to the issue that the file is linked to - as a result of this work, the FileClass has a default MIME type that may be overridden in a subclass, or by the use of a "type" property as is done in the default templates. - the regeneration of the indexes (if necessary) is done once the schema is set up in the dbinit.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 09 Jul 2002 03:02:53 +0000
parents 60189cf7ba8e
children 6d7a45c8464a
line wrap: on
line diff
--- a/roundup/roundupdb.py	Tue Jul 09 01:21:24 2002 +0000
+++ b/roundup/roundupdb.py	Tue Jul 09 03:02:53 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: roundupdb.py,v 1.59 2002-06-18 03:55:25 dman13 Exp $
+# $Id: roundupdb.py,v 1.60 2002-07-09 03:02:52 richard Exp $
 
 __doc__ = """
 Extending hyperdb with types specific to issue-tracking.
@@ -227,6 +227,16 @@
             react(self.db, self, nodeid, oldvalues)
 
 class FileClass(Class):
+    '''This class defines a large chunk of data. To support this, it has a
+       mandatory String property "content" which is typically saved off
+       externally to the hyperdb.
+
+       The default MIME type of this data is defined by the
+       "default_mime_type" class attribute, which may be overridden by each
+       node if the class defines a "type" String property.
+    '''
+    default_mime_type = 'text/plain'
+
     def create(self, **propvalues):
         ''' snaffle the file propvalue and store in a file
         '''
@@ -264,6 +274,28 @@
             d['content'] = hyperdb.String()
         return d
 
+    def index(self, nodeid):
+        ''' Index the node in the search index.
+
+            We want to index the content in addition to the normal String
+            property indexing.
+        '''
+        # perform normal indexing
+        Class.index(self, nodeid)
+
+        # get the content to index
+        content = self.get(nodeid, 'content')
+
+        # figure the mime type
+        if self.properties.has_key('type'):
+            mime_type = self.get(nodeid, 'type')
+        else:
+            mime_type = self.default_mime_type
+
+        # and index!
+        self.db.indexer.add_text((self.classname, nodeid, 'content'), content,
+            mime_type)
+
 class MessageSendError(RuntimeError):
     pass
 
@@ -659,6 +691,10 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.59  2002/06/18 03:55:25  dman13
+# Fixed name/address display problem introduced by an earlier change.
+# (instead of "name<addr>" display "name <addr>")
+#
 # Revision 1.58  2002/06/16 01:05:15  dman13
 # Removed temporary workaround -- it seems it was a bug in the
 # nosyreaction detector in the 0.4.1 extended template and has already

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