MonScoDocEssai/app/views/__init__.py

31 lines
901 B
Python

# -*- coding: UTF-8 -*
"""ScoDoc Flask views
"""
from flask import Blueprint
from flask import g
from app.scodoc import notesdb as ndb
scodoc_bp = Blueprint("scodoc", __name__)
scolar_bp = Blueprint("scolar", __name__)
notes_bp = Blueprint("notes", __name__)
users_bp = Blueprint("users", __name__)
absences_bp = Blueprint("absences", __name__)
essais_bp = Blueprint("essais", __name__)
@scodoc_bp.before_app_request
def open_dept_db_connection():
# current_app.logger.info("open_dept_db_connection")
if hasattr(g, "scodoc_dept") and not hasattr(g, "db_conn") and g.scodoc_dept:
g.db_conn = ndb.open_dept_connection()
@scodoc_bp.teardown_app_request
def close_dept_db_connection(arg):
# current_app.logger.info("close_dept_db_connection")
if hasattr(g, "db_conn"):
ndb.close_dept_connection()
from app.views import scodoc, notes, scolar, absences, users, essais