# Path: src/config.py
# UPLOAD_CHUNK_LENGTH = 8 * _1MB
# 
# UPLOAD_UNSAVORY_EXTS = ['bat', 'cmd', 'exe', 'iso', 'php', 'vbs']
# 
# UPLOADED_FILES_DEST = '/tmp'
# 
# Path: src/forms.py
# class UserForm(ModelForm):
#     class Meta:
#         model = Users
#         exclude = common_exclusions
#         #~ only = tuple('''
#             #~ name email timezone desc
#         #~ '''.split())
#         only = tuple('name email timezone desc'.split())
# 
# Path: src/logcfg.py
# DEBUG_TEMPL = '  %(levelname)-7.7s %(funcName)s: %(message)s'
# PROD_TEMPL  = '%(asctime)s %(levelname)-7.7s %(funcName)s: %(message)s'
# DEBUG = logging.DEBUG
# class ColorFmtr(Formatter):
#     def __init__(self, *args, **kwargs):
#     def format(self, record):
# def makefunc(level):
#         def tb_func(msg, *args, **kwargs):
#     def thefunc(msg, *args, **kwargs):
# 
# Path: src/main.py
# def on_shutdown():


from os.path import join, splitext
from http_status import name as http_status_text
from http_status import description as http_status_description
from flask import (
    #~ abort,
    flash,      # flash categories: success, (blank) info, warning, error
    #~ g,
    jsonify,
    redirect,
    render_template as render,
    request,
    url_for,
)
from flask_login import current_user
from sqlalchemy.exc import SQLAlchemyError
from werkzeug.utils import secure_filename
from .config import (UPLOAD_CHUNK_LENGTH, UPLOAD_UNSAVORY_EXTS,
                     UPLOADED_FILES_DEST)
from .forms import UserForm
from .logcfg import log
from .main import app, db
from . import utils
'''
    Controllers/views for the web interface are defined here.
'''


#~ from .models import Users


SKIP_LOGIN = ('static', '_default_auth_request_handler')
app_debug = app.debug
sec_bp = app.config.get('SECURITY_BLUEPRINT_NAME', 'security')


@app.before_request
def before_request():
    ''' Every request should be logged-in, thanks. '''
    endpoint = request.endpoint
    if app_debug:
        if endpoint not in ('static', 'admin.static', '_debug_toolbar.static'):

# Path: src/config.py
# UPLOAD_CHUNK_LENGTH = 8 * _1MB
# 
# UPLOAD_UNSAVORY_EXTS = ['bat', 'cmd', 'exe', 'iso', 'php', 'vbs']
# 
# UPLOADED_FILES_DEST = '/tmp'
# 
# Path: src/forms.py
# class UserForm(ModelForm):
#     class Meta:
#         model = Users
#         exclude = common_exclusions
#         #~ only = tuple('''
#             #~ name email timezone desc
#         #~ '''.split())
#         only = tuple('name email timezone desc'.split())
# 
# Path: src/logcfg.py
# DEBUG_TEMPL = '  %(levelname)-7.7s %(funcName)s: %(message)s'
# PROD_TEMPL  = '%(asctime)s %(levelname)-7.7s %(funcName)s: %(message)s'
# DEBUG = logging.DEBUG
# class ColorFmtr(Formatter):
#     def __init__(self, *args, **kwargs):
#     def format(self, record):
# def makefunc(level):
#         def tb_func(msg, *args, **kwargs):
#     def thefunc(msg, *args, **kwargs):
# 
# Path: src/main.py
# def on_shutdown():


# Path: src/views.py
from os.path import join, splitext
from http_status import name as http_status_text
from http_status import description as http_status_description
from flask import (
    #~ abort,
    flash,      # flash categories: success, (blank) info, warning, error
    #~ g,
    jsonify,
    redirect,
    render_template as render,
    request,
    url_for,
)
from flask_login import current_user
from sqlalchemy.exc import SQLAlchemyError
from werkzeug.utils import secure_filename
from .config import (UPLOAD_CHUNK_LENGTH, UPLOAD_UNSAVORY_EXTS,
                     UPLOADED_FILES_DEST)
from .forms import UserForm
from .logcfg import log
from .main import app, db
from . import utils

'''
    Controllers/views for the web interface are defined here.
'''


#~ from .models import Users


SKIP_LOGIN = ('static', '_default_auth_request_handler')
app_debug = app.debug
sec_bp = app.config.get('SECURITY_BLUEPRINT_NAME', 'security')


@app.before_request
def before_request():
    ''' Every request should be logged-in, thanks. '''
    endpoint = request.endpoint
    if app_debug:
        if endpoint not in ('static', 'admin.static', '_debug_toolbar.static'):

            log.note('endpoint: %s  user: %s  auth: %s  bp: %s', endpoint,