view MoinMoin/macro/ @ 3175:2a3a6cb34e45

pylint findings: fix some harmless stuff
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 03 Mar 2008 02:02:55 +0100
parents 388204baf00f
children 475f8094a65f
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - Hits Macro

    This macro is used to show the cumulative hits of the wikipage where the Macro is called from.
    Optionally you could count how much this page or all pages were changed or viewed.


        all: if set to 1/True/yes then cumulative hits over all wiki pages is returned.
             Default is 0/False/no.
        filter: if set to SAVEPAGE then the saved pages are counted. Default is VIEWPAGE.

   @copyright: 2004-2007 MoinMoin:ReimarBauer,
               2005 BenjaminVrolijk
   @license: GNU GPL, see COPYING for details.

Dependencies = ['time'] # do not cache

from MoinMoin.logfile import eventlog

def macro_Hits(macro, all=False, filter=(u'VIEWPAGE', u'SAVEPAGE')):
    this_page =
    event_log = eventlog.EventLog(macro.request)
    count = 0
    for event in event_log.reverse():
        pagename = event[2].get('pagename')
        if all or pagename == this_page:
            count += 1

    return u'%d' % count