Mercurial > p > roundup > code
diff roundup/backends/indexer_common.py @ 3997:edbb89730dc2
Fix indexer handling of indexed Link properties
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 18 Aug 2008 06:57:49 +0000 |
| parents | 44603dd791b7 |
| children | 20c9a1cefb39 |
line wrap: on
line diff
--- a/roundup/backends/indexer_common.py Mon Aug 18 06:44:46 2008 +0000 +++ b/roundup/backends/indexer_common.py Mon Aug 18 06:57:49 2008 +0000 @@ -1,4 +1,4 @@ -#$Id: indexer_common.py,v 1.8 2006-11-11 03:01:54 richard Exp $ +#$Id: indexer_common.py,v 1.9 2008-08-18 06:57:49 richard Exp $ import re, sets from roundup import hyperdb @@ -8,7 +8,7 @@ "FOR", "IF", "IN", "INTO", "IS", "IT", "NO", "NOT", "OF", "ON", "OR", "SUCH", "THAT", "THE", "THEIR", "THEN", "THERE", "THESE", - "THEY", "THIS", "TO", "WAS", "WILL", "WITH" + "THEY", "THIS", "TO", "WAS", "WILL", "WITH" ] def _isLink(propclass): @@ -26,7 +26,7 @@ def getHits(self, search_terms, klass): return self.find(search_terms) - + def search(self, search_terms, klass, ignore={}): '''Display search results looking for [search, terms] associated with the hyperdb Class "klass". Ignore hits on {class: property}. @@ -81,6 +81,7 @@ del propspec[propname] # klass.find tells me the klass nodeids the linked nodes relate to + propdefs = klass.getprops() for resid in klass.find(**propspec): resid = str(resid) if not nodeids.has_key(id): @@ -88,7 +89,12 @@ node_dict = nodeids[resid] # now figure out where it came from for linkprop in propspec.keys(): - for nodeid in klass.get(resid, linkprop): + v = klass.get(resid, linkprop) + # the link might be a Link so deal with a single result or None + if isinstance(propdefs[linkprop], hyperdb.Link): + if v is None: continue + v = [v] + for nodeid in v: if propspec[linkprop].has_key(nodeid): # OK, this node[propname] has a winner if not node_dict.has_key(linkprop):
