Back to index

moin  1.9.0~rc2
chart.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - show some statistics chart
00004 
00005     @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
00006                 2006 MoinMoin:ThomasWaldmann
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 from MoinMoin.util import pysupport
00010 
00011 def execute(pagename, request):
00012     """ Show page charts """
00013     _ = request.getText
00014     if not request.user.may.read(pagename):
00015         request.theme.add_msg(_("You are not allowed to view this page."), "error")
00016         return request.page.send_page()
00017 
00018     if not request.cfg.chart_options:
00019         request.theme.add_msg(_("Charts are not available!"), "error")
00020         return request.page.send_page()
00021 
00022     chart_type = request.values.get('type', '').strip()
00023     if not chart_type:
00024         request.theme.add_msg(_('You need to provide a chart type!'), "error")
00025         return request.page.send_page()
00026 
00027     try:
00028         func = pysupport.importName("MoinMoin.stats.%s" % chart_type, 'draw')
00029     except (ImportError, AttributeError):
00030         request.theme.add_msg(_('Bad chart type "%s"!') % chart_type, "error")
00031         return request.page.send_page()
00032 
00033     func(pagename, request)
00034