Back to index

moin  1.9.0~rc2
PageCount.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     Outputs the page count of the wiki.
00004 
00005     @copyright: 2007 MoinMoin:ThomasWaldmann
00006     @license: GNU GPL, see COPYING for details
00007 """
00008 
00009 Dependencies = ['namespace']
00010 
00011 from MoinMoin import wikiutil
00012 
00013 def macro_PageCount(macro, exists=None):
00014     """ Return number of pages readable by current user
00015 
00016     Return either an exact count (slow!) or fast count including deleted pages.
00017 
00018     TODO: make macro syntax more sane
00019     """
00020     request = macro.request
00021     exists = wikiutil.get_unicode(request, exists, 'exists')
00022     # Check input
00023     only_existing = False
00024     if exists == u'exists':
00025         only_existing = True
00026     elif exists:
00027         raise ValueError("Wrong argument: %r" % exists)
00028 
00029     count = request.rootpage.getPageCount(exists=only_existing)
00030     return macro.formatter.text("%d" % count)
00031