Commit 3bfa3abe authored by Julian Rother's avatar Julian Rother

Moved handler registration to server.py to reduce module dependencies

parent 0f151bec
......@@ -119,18 +119,6 @@ def getfielddescription(path):
desc = '<br>'+desc
return desc
edit_handlers = {}
def edit_handler(*tables, field=None):
def wrapper(func):
for table in tables:
if table not in edit_handlers:
edit_handlers[table] = {}
if field not in edit_handlers[table]:
edit_handlers[table][field] = []
edit_handlers[table][field].append(func)
return func
return wrapper
@app.route('/internal/edit', methods=['GET', 'POST'])
@mod_required
@csrf_protect
......
......@@ -99,25 +99,6 @@ def jobs_worker_ping(hostname):
query('REPLACE INTO worker (hostname, last_ping) values (?, ?)', hostname, datetime.now())
return 'OK',200
job_handlers = {}
def job_handler(*types, state='finished'):
def wrapper(func):
for jobtype in types:
if jobtype not in job_handlers:
job_handlers[jobtype] = {}
if jobtype not in job_handlers[jobtype]:
job_handlers[jobtype][state] = []
job_handlers[jobtype][state].append(func)
return func
return wrapper
def schedule_job(jobtype, data=None, priority=0):
if not data:
data = {}
modify('INSERT INTO jobs (type, priority, data, time_created) VALUES (?, ?, ?, ?)',
jobtype, priority, json.dumps(data, default=date_json_handler), datetime.now())
@app.route('/internal/jobs/api/job/<int:id>/ping', methods=['GET', 'POST'])
@jobs_api_token_required
def jobs_ping(id):
......
......@@ -461,14 +461,45 @@ def dbstatus():
clusters[cluster].append(host)
return render_template('dbstatus.html', clusters=clusters, statuses=status, vars=variables), 200
from edit import edit_handler
job_handlers = {}
def job_handler(*types, state='finished'):
def wrapper(func):
for jobtype in types:
if jobtype not in job_handlers:
job_handlers[jobtype] = {}
if jobtype not in job_handlers[jobtype]:
job_handlers[jobtype][state] = []
job_handlers[jobtype][state].append(func)
return func
return wrapper
def schedule_job(jobtype, data=None, priority=0):
if not data:
data = {}
modify('INSERT INTO jobs (type, priority, data, time_created) VALUES (?, ?, ?, ?)',
jobtype, priority, json.dumps(data, default=date_json_handler), datetime.now())
edit_handlers = {}
def edit_handler(*tables, field=None):
def wrapper(func):
for table in tables:
if table not in edit_handlers:
edit_handlers[table] = {}
if field not in edit_handlers[table]:
edit_handlers[table][field] = []
edit_handlers[table][field].append(func)
return func
return wrapper
import edit
import feeds
import importer
import stats
if 'ICAL_URL' in config:
import meetings
import l2pauth
from jobs import job_handler, schedule_job
import jobs
import sorter
import encoding
import timetable
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment