MobileBlur

toolbar.py at [b28babbbb4]
Login

toolbar.py at [b28babbbb4]

File applications/admin/controllers/toolbar.py artifact f7ea6cbe56 part of check-in b28babbbb4


import os
from gluon.settings import global_settings, read_file
#

def index():
    app = request.args(0)
    return dict(app=app)

def profiler():
    """
    to use the profiler start web2py with -F profiler.log
    """
    KEY = 'web2py_profiler_size'
    filename = global_settings.cmd_options.profiler_filename
    data = 'profiler disabled'
    if filename:
        if  KEY in request.cookies:
            size = int(request.cookies[KEY].value)
        else:
            size = 0
        if os.path.exists(filename):
            data = read_file('profiler.log','rb')
            if size<len(data): 
                data = data[size:]
            else: 
                size=0
            size += len(data)
            response.cookies[KEY] = size
    return data