[mb-commits] r9916 - in search_server/trunk: bin lib
root at musicbrainz.org
root at musicbrainz.org
Mon Jun 30 08:38:10 UTC 2008
Author: robert
Date: 2008-06-30 08:38:09 +0000 (Mon, 30 Jun 2008)
New Revision: 9916
Modified:
search_server/trunk/bin/handler.fcgi
search_server/trunk/lib/annotationsearch.py
search_server/trunk/lib/freedbsearch.py
Log:
Ported freedbsearch to xapian.
Fixed error handling routines.
Shuddered at: "luks: (added by WMP, as they have some AMG IDs in them)"
Modified: search_server/trunk/bin/handler.fcgi
===================================================================
--- search_server/trunk/bin/handler.fcgi 2008-06-30 01:44:58 UTC (rev 9915)
+++ search_server/trunk/bin/handler.fcgi 2008-06-30 08:38:09 UTC (rev 9916)
@@ -116,14 +116,10 @@
searchobj.setShowRelationshipLink(rel);
try:
content = searchobj.search(query, maxHits, offset, fmt)
- except search.QueryError, e:
- text = e.message
+ except search.QueryError, text:
+ text = str(text)
text += "\n"
- if text.startswith(u'org.apache.lucene.queryParser.'):
- text = text[30:]
- if text.startswith(u'org.apache.lucene.search.'):
- text = text[25:]
- start_response('403 BAD REQUEST', [('Content-Type', 'text/plain')])
+ start_response('400 BAD REQUEST', [('Content-Type', 'text/plain')])
return text.encode('utf-8', 'replace')
except search.SearchError:
start_response('500 INTERNAL SERVER ERROR', [('Content-Type', 'text/plain')])
Modified: search_server/trunk/lib/annotationsearch.py
===================================================================
--- search_server/trunk/lib/annotationsearch.py 2008-06-30 01:44:58 UTC (rev 9915)
+++ search_server/trunk/lib/annotationsearch.py 2008-06-30 08:38:09 UTC (rev 9916)
@@ -57,7 +57,7 @@
out += u"<td><span class=\"link%s-icon\"><a href=\"/%s/%s.html\">%s</a></td>" % (self.escape(type), self.escape(type),
self.escape(mbid), self.escape(name))
- text = text.replace(u"\\n", u"\n");
+ text = text.replace(u"\\n", u"\n")
out += u"<td>%%WIKIBEGIN%%%s%%WIKIEND%%</td>" % (self.escape(text))
out += u"</tr>"
out += u"</table></div>"
Modified: search_server/trunk/lib/freedbsearch.py
===================================================================
--- search_server/trunk/lib/freedbsearch.py 2008-06-30 01:44:58 UTC (rev 9915)
+++ search_server/trunk/lib/freedbsearch.py 2008-06-30 08:38:09 UTC (rev 9916)
@@ -29,7 +29,7 @@
class FreeDBSearch(search.TextSearch):
'''
- This class derives from TextSearch and outputs HTML for lucene query hits
+ This class derives from TextSearch and outputs HTML for query hits
'''
def __init__(self, index):
@@ -37,6 +37,11 @@
self.setDefaultField('title')
self.setPrefixes(('title', 'artist', 'tracks', 'cat', 'discid', 'year'))
+ def reescape(self, text):
+ if not text: return ""
+ text = text.replace(u"\\n", u"\n");
+ return self.escape(text)
+
def asHTML(self, hits, maxHits, offset):
'''
Output a freedb search result as HTML
@@ -44,18 +49,18 @@
out = u'<div><table class="searchresults">'
out += u'<tr class="searchresultsheader"><td>Score</td><td>Title</td>'
- out += u'<td>Artist</td><td>Tracks</td><td>Discid</td><td>Year</td><td>Action</td></tr>'
- for doc in hits:
+ out += u'<td>Artist</td><td>Tracks</td><td>Cat/Discid</td><td>Year</td><td>Action</td></tr>'
+ for i, doc in enumerate(hits):
out += u'<tr class="searchresults%s">' % search.oddeven[i % 2]
- out += u"<td>%d</td>" % int(hits.score(i) * 100)
- out += u"<td>%s</td>" % self.escape(doc.get('title'))
- out += u"<td>%s</td>" % self.escape(doc.get('artist'))
- out += u"<td>%s</td>" % self.escape(doc.get('tracks'))
- out += u"<td>%s / " % self.escape(doc.get('cat'))
- out += u"%s</a></td>" % self.escape(doc.get('discid'))
- out += u"<td>%s</td>" % self.escape(doc.get('year'))
- out += u'<td><a href="/freedb/import.html?catid=%s/%s">import</a></td>' % (self.escape(doc.get('cat')),
- self.escape(doc.get('discid')))
+ out += u"<td>%d</td>" % doc['_score']
+ out += u"<td>%s</td>" % self.reescape(doc.get('title'))
+ out += u"<td>%s</td>" % self.reescape(doc.get('artist'))
+ out += u"<td>%s</td>" % self.reescape(doc.get('tracks'))
+ out += u"<td>%s / " % self.reescape(doc.get('cat'))
+ out += u"%s</a></td>" % self.reescape(doc.get('discid'))
+ out += u"<td>%s</td>" % self.reescape(doc.get('year'))
+ out += u'<td><a href="/freedb/import.html?catid=%s/%s">import</a></td>' % (self.reescape(doc.get('cat')),
+ self.reescape(doc.get('discid')))
out += u"</tr>"
out += u"</table></div>"
return out
More information about the MusicBrainz-commits
mailing list