Mercurial > p > roundup > code
comparison roundup/backends/back_tsearch2.py @ 3061:b0f5ea4e4dff
First fixes for Python 2.1 compatibility:
* don't use booleans
* don't use a string > 1 char with 'in'
* use has_key instead of 'in' for dictionaries
| author | Johannes Gijsbers <jlgijsbers@users.sourceforge.net> |
|---|---|
| date | Wed, 05 Jan 2005 21:50:03 +0000 |
| parents | 1c063814d567 |
| children | 2817a4db901d |
comparison
equal
deleted
inserted
replaced
| 3060:53d1d4e2015c | 3061:b0f5ea4e4dff |
|---|---|
| 87 def __init__(self, db): | 87 def __init__(self, db): |
| 88 self.db = db | 88 self.db = db |
| 89 | 89 |
| 90 # This indexer never needs to reindex. | 90 # This indexer never needs to reindex. |
| 91 def should_reindex(self): | 91 def should_reindex(self): |
| 92 return False | 92 return 0 |
| 93 | 93 |
| 94 def getHits(self, search_terms, klass): | 94 def getHits(self, search_terms, klass): |
| 95 return self.find(search_terms, klass) | 95 return self.find(search_terms, klass) |
| 96 | 96 |
| 97 def find(self, search_terms, klass): | 97 def find(self, search_terms, klass): |
| 118 nodeids = [str(row[0]) for row in self.db.cursor.fetchall()] | 118 nodeids = [str(row[0]) for row in self.db.cursor.fetchall()] |
| 119 | 119 |
| 120 # filter out files without text/plain mime type | 120 # filter out files without text/plain mime type |
| 121 # XXX: files without text/plain shouldn't be indexed at all, we | 121 # XXX: files without text/plain shouldn't be indexed at all, we |
| 122 # should take care of this in the trigger | 122 # should take care of this in the trigger |
| 123 if 'type' in klass.getprops(): | 123 if klass.getprops().has_key('type'): |
| 124 nodeids = [nodeid for nodeid in nodeids | 124 nodeids = [nodeid for nodeid in nodeids |
| 125 if klass.get(nodeid, 'type') == 'text/plain'] | 125 if klass.get(nodeid, 'type') == 'text/plain'] |
| 126 | 126 |
| 127 # XXX: We haven't implemented property-level search, so I'm just faking | 127 # XXX: We haven't implemented property-level search, so I'm just faking |
| 128 # it here with a property named 'XXX'. We still need to fix the other | 128 # it here with a property named 'XXX'. We still need to fix the other |
| 157 Class.__init__(self, db, classname, **properties) | 157 Class.__init__(self, db, classname, **properties) |
| 158 | 158 |
| 159 default_mime_type = 'text/plain' | 159 default_mime_type = 'text/plain' |
| 160 def create(self, **propvalues): | 160 def create(self, **propvalues): |
| 161 # figure the mime type | 161 # figure the mime type |
| 162 if 'type' in self.getprops() and not propvalues.get('type'): | 162 if self.getprops().has_key('type') and not propvalues.get('type'): |
| 163 propvalues['type'] = self.default_mime_type | 163 propvalues['type'] = self.default_mime_type |
| 164 return Class.create(self, **propvalues) | 164 return Class.create(self, **propvalues) |
| 165 | 165 |
| 166 def export_files(self, dirname, nodeid): | 166 def export_files(self, dirname, nodeid): |
| 167 dest = self.exportFilename(dirname, nodeid) | 167 dest = self.exportFilename(dirname, nodeid) |
