changeset 2539:9dd4a7a164e4

use new features in Hits macro
author Johannes Berg <johannes AT sipsolutions DOT net>
date Mon, 23 Jul 2007 19:34:54 +0200
parents 070294763d3e
children fa4252cb4077
files MoinMoin/macro/Hits.py
diffstat 1 files changed, 4 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/Hits.py	Mon Jul 23 19:34:40 2007 +0200
+++ b/MoinMoin/macro/Hits.py	Mon Jul 23 19:34:54 2007 +0200
@@ -22,23 +22,14 @@
 from MoinMoin.logfile import eventlog
 
 
-def macro_Hits(macro, all=None, filter=None):
-    request = macro.request
-    _ = request.getText
+def macro_Hits(macro, all=False, filter=(u'VIEWPAGE', u'SAVEPAGE')):
     this_page = macro.formatter.page.page_name
-    event_filter = str(wikiutil.get_unicode(request, filter, 'filter', u'VIEWPAGE'))
-    filters_possible = ('VIEWPAGE', 'SAVEPAGE')
-    if not event_filter in filters_possible:
-        raise ValueError(_("filter argument must be one of %s") % (', '.join(filters_possible)))
-    count_all_pages = wikiutil.get_bool(request, all, 'all', False)
-
-    event_log = eventlog.EventLog(request)
-    event_log.set_filter([event_filter])
+    event_log = eventlog.EventLog(macro.request)
+    event_log.set_filter([str(filter)])
     count = 0
     for event in event_log.reverse():
         pagename = event[2].get('pagename')
-        if count_all_pages or pagename == this_page:
+        if all or pagename == this_page:
             count += 1
 
     return u'%d' % count
-