annotate MoinMoin/macro/Hits.py @ 3431:b64bd80bd53c

fixed some doc strings
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 29 Mar 2008 22:28:46 +0100
parents aa3890b17212
children
rev   line source
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - Hits Macro
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
2514
9065adc695ca refactored Hits macro for new arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2455
diff changeset
5 This macro is used to show the cumulative hits of the wikipage where the Macro is called from.
9065adc695ca refactored Hits macro for new arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2455
diff changeset
6 Optionally you could count how much this page or all pages were changed or viewed.
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7
3431
b64bd80bd53c fixed some doc strings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3424
diff changeset
8 <<Hits([all=(0,1)],[event_type=(VIEWPAGE,SAVEPAGE)>>
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9
2514
9065adc695ca refactored Hits macro for new arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2455
diff changeset
10 all: if set to 1/True/yes then cumulative hits over all wiki pages is returned.
9065adc695ca refactored Hits macro for new arg parser
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2455
diff changeset
11 Default is 0/False/no.
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 filter: if set to SAVEPAGE then the saved pages are counted. Default is VIEWPAGE.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2054
diff changeset
13
3422
b9c90178b93a macro.Hits: refactored
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3384
diff changeset
14 @copyright: 2004-2008 MoinMoin:ReimarBauer,
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 2005 BenjaminVrolijk
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16 @license: GNU GPL, see COPYING for details.
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 """
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 Dependencies = ['time'] # do not cache
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19
3424
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
20 from MoinMoin.stats import hitcounts
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21
3422
b9c90178b93a macro.Hits: refactored
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3384
diff changeset
22 def macro_Hits(macro, all=False, event_type=(u'VIEWPAGE', u'SAVEPAGE')):
3424
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
23 request = macro.request
3422
b9c90178b93a macro.Hits: refactored
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3384
diff changeset
24 pagename = macro.formatter.page.page_name
3424
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
25
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
26 if all:
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
27 cache_days, cache_views, cache_edits = hitcounts.get_data(pagename, request, filterpage=None)
3422
b9c90178b93a macro.Hits: refactored
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3384
diff changeset
28 else:
3424
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
29 cache_days, cache_views, cache_edits = hitcounts.get_data(pagename, request, filterpage=pagename)
2054
9bea36ddd065 macro/Hits: shows hits of a page (refactored version from MacroMarket)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30
3424
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
31 if event_type == u'VIEWPAGE':
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
32 return u'%d' % sum(cache_views)
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
33 else:
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
34 return u'%d' % sum(cache_edits)
aa3890b17212 macro.Hits: incredible speed up using MoinMoin.stats.hitcounts
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3422
diff changeset
35