reports.py 1.42 KiB
""" Collection of controllers to build reports
"""
from plugin_dbui import Selector
def index():
"""Main Controller handling report.
"""
return 'Report section'
def report_1():
"""First trial
"""
return "report_1"
def report_2():
"""Return the URL arguments
"""
import time
selector = Selector(virtdb.foo1)
# simulate a rather long processing
time.sleep(5)
# standard response with the selected values
return dict(test=selector.as_dict(), vars=request.vars)
def report_3():
"""Return the URL arguments
"""
selector = Selector(virtdb.harvester_selector)
response.view = 'reports/report_2.html'
return dict(test=selector.as_dict())
def report_4():
"""Execute a javascript in the view using python information
"""
import json
cfg = dict(groupField='controller')
cfg['fields'] = [{'name': 'controller', 'type': 'string'},
{'name': 'host', 'type': 'string'},
{'name': 'collections', 'type': 'string'},
{'name': 'ratio', 'type': 'number'}]
cfg['data'] = []
for row in db().select(db.harvesters.ALL):
cfg['data'].append([row.controller,
row.host,
row.collections,
row.ratio])
return dict(msg="Hello world", cfg_store=json.dumps(cfg))