changeset 1663:54075f263950

search results processing: make code better debuggable, catch empty revisions list case
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 06 Nov 2006 15:21:17 +0100
parents 3338af3c3867
children 255a340ca616
files MoinMoin/search/results.py
diffstat 1 files changed, 17 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/results.py	Wed Nov 01 23:55:39 2006 +0100
+++ b/MoinMoin/search/results.py	Mon Nov 06 15:21:17 2006 +0100
@@ -719,30 +719,29 @@
     def formatHitInfoBar(self, page):
         """ Returns the code for the information below a search hit
 
-        @param page: the page instance
+        @param page: the FoundPage instance
         """
+        request = self.request
         f = self.formatter
-        _ = self.request.getText
-        request = self.request
+        _ = request.getText
+        p = page.page
 
-        rev = page.page.get_real_rev()
+        rev = p.get_real_rev()
         if rev is None:
             rev = 0
 
-        return ''.join([
-            f.paragraph(1, attr={'class': 'searchhitinfobar'}),
-            f.text('%.1fk - ' % (page.page.size()/1024.0)),
-            f.text('rev: %d %s- ' % (rev,
-                rev == page.page.getRevList()[0] and
-                '(%s) ' % _('current') or '')),
-            f.text('last modified: %s' % page.page.mtime_printable(request)),
-            # XXX: proper metadata
-            #f.text('lang: %s - ' % page.page.language),
-            #f.url(1, href='#'),
-            #f.text(_('Similar pages')),
-            #f.url(0),
-            f.paragraph(0),
-        ])
+        size_str = '%.1fk' % (p.size()/1024.0)
+        revisions = p.getRevList()
+        if len(revisions) and rev == revisions[0]:
+            rev_str = 'rev: %d (%s)' % (rev, _('current'))
+        else:
+            rev_str = 'rev: %d' % (rev, )
+        lastmod_str = _('last modified: %s') % p.mtime_printable(request)
+
+        result = f.paragraph(1, attr={'class': 'searchhitinfobar'}) + \
+                 f.text('%s - %s %s' % (size_str, rev_str, lastmod_str)) + \
+                 f.paragraph(0)
+        return result
 
     def querystring(self, querydict=None):
         """ Return query string, used in the page link