Skip to content
Snippets Groups Projects
reports.py 1.7 KiB
Newer Older
Renaud Le Gac's avatar
Renaud Le Gac committed
""" Collection of controllers to build reports 
Renaud Le Gac's avatar
Renaud Le Gac committed
"""
from plugin_dbui import Selector


def index():
    """Main Controller handling report.
    """
    return 'Report section'


def report_1():
legac's avatar
legac committed
    import time
    
    selector = Selector(virtdb.foo1)
    # simulate a rather long processing    
legac's avatar
legac committed
    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
    
    """
    selector = Selector(virtdb.report4)
    
    cfg.fields = [dict(name='controller', type='string'),
                  dict(name='host', type='string'),
                  dict(name='collections', type='string'),
                  dict(name='ratio', type='number')]

    if selector.grouping or selector.grouping_summary:
    for row in db().select(db.harvesters.ALL):
        
        di = dict(controller=row.controller,
                  host='<a href="http://www.web2py.com">%s</a>' % row.host,
                  collections=row.collections,
                  ratio=row.ratio)
        
        cfg['data'].append(di)
    return dict(msg="Hello world", 
                cfg_store=json.dumps(cfg), 
                selector=json.dumps(selector))