Skip to content
Snippets Groups Projects
Commit 761a55d8 authored by Julian Rother's avatar Julian Rother
Browse files

Implemented auto-generation of a static 500-Page

parent 8b45d498
No related branches found
No related tags found
No related merge requests found
...@@ -3,3 +3,4 @@ config.py ...@@ -3,3 +3,4 @@ config.py
__pycache__ __pycache__
*.sqlite *.sqlite
files/* files/*
static/500.html
...@@ -20,3 +20,4 @@ SQLITE_INIT_DATA = False ...@@ -20,3 +20,4 @@ SQLITE_INIT_DATA = False
#LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de' #LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de'
#ICAL_URL = 'https://user:password@mail.fsmpi.rwth-aachen.de/SOGo/....ics' #ICAL_URL = 'https://user:password@mail.fsmpi.rwth-aachen.de/SOGo/....ics'
ERROR_PAGE = 'static/500.html'
...@@ -179,6 +179,16 @@ def handle_internal_error(e): ...@@ -179,6 +179,16 @@ def handle_internal_error(e):
traceback.print_exc() traceback.print_exc()
return render_template('500.html') return render_template('500.html')
@sched_func(5*60, firstdelay=0)
def dump_error_page():
if 'ERROR_PAGE' not in config:
return
request.url_rule = Rule(request.path, endpoint='handle_internal_error')
text = render_template('500.html')
f = open(config['ERROR_PAGE'], 'w')
f.write(text)
f.close()
# debian ships jinja2 without this test... # debian ships jinja2 without this test...
@app.template_test(name='equalto') @app.template_test(name='equalto')
def equalto(a,b): def equalto(a,b):
...@@ -426,7 +436,6 @@ def edit(prefix='', ignore=[]): ...@@ -426,7 +436,6 @@ def edit(prefix='', ignore=[]):
@app.route('/new/<table>', methods=['GET', 'POST']) @app.route('/new/<table>', methods=['GET', 'POST'])
@mod_required @mod_required
def create(table): def create(table):
print(table, request.values)
assert table in tabs assert table in tabs
defaults = {'created_by': session['user']['dbid'], 'time_created': datetime.now(), 'time_updated': datetime.now()} defaults = {'created_by': session['user']['dbid'], 'time_created': datetime.now(), 'time_updated': datetime.now()}
columns = [] columns = []
...@@ -445,7 +454,6 @@ def create(table): ...@@ -445,7 +454,6 @@ def create(table):
assert column not in defaults assert column not in defaults
columns.append(column) columns.append(column)
values.append(val) values.append(val)
print(columns, values)
id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0], id = modify('INSERT INTO %s (%s) VALUES (%s)'%(tabs[table][0],
','.join(columns), ','.join(['?']*len(values))), *values) ','.join(columns), ','.join(['?']*len(values))), *values)
if 'ref' in request.values: if 'ref' in request.values:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<div class="panel panel-danger"> <div class="panel panel-danger">
<div class="panel-heading"> <div class="panel-heading">
<h1 class="panel-title">Interner Fehler (500)</h1> <h1 class="panel-title">Interner Fehler</h1>
</div> </div>
<div class="row panel-body"> <div class="row panel-body">
<div class="col-xs-12"> <div class="col-xs-12">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment