forked from renefritze/spring-infolog
/
recordlist.py
32 lines (28 loc) · 972 Bytes
/
recordlist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
from bottle import route,request
from siteglobals import env, db, config, cache
from utils import *
from backend import Crash
from sprox.tablebase import TableBase
from sprox.fillerbase import TableFiller
class CrashTableFiller(TableFiller):
__model__ = Crash
def date(self,crash):
dates = '<a href="/details?id=%d">%s</a>'%(crash.id,str(crash.date))
return dates
class CrashTable( TableBase ):
__model__ = Crash
__omit_fields__ = ['id', 'extensions', '__actions__','settings','filename','script']
__xml_fields__=['date']
@cache.cache('list_output', expire=60)
@route('/list', method='GET')
def output():
try:
session = db.sessionmaker()
crash_table = CrashTable(session)
crash_filler = CrashTableFiller(session)
ret = env.get_template('list.html').render( widget=crash_table, value=crash_filler.get_value() )
session.close()
return ret
except Exception, m:
return env.get_template('error.html').render(err_msg=str(m))