# 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
    form.populate_obj(user)     # handle update + unique constraints

    if request.method == 'POST':
        try:
            form.validate()
            for field in form:
                setattr(user, field.short_name, field.data)
            db.session.commit()
            flash('User updated.', 'success')
        except SQLAlchemyError as err:
            log.error(str(err))
            db.session.rollback()
            flash('Database: %s' % err.orig, 'error')

        return redirect(url_for('show_profile'))

    return render('profile.html', title='Profile Page', form=form)


@app.route('/upload', methods=('GET', 'POST'))
def upload_file():
    if request.method == 'POST':
        files = request.files.getlist('files[]')
        for f in files:
            # double check for errors that made it thru javascript gauntlet:
            filename = secure_filename(f.filename)
            if filename == '':
                flash('No files selected.', 'error')
                return redirect(request.url)


# 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

    form.populate_obj(user)     # handle update + unique constraints

    if request.method == 'POST':
        try:
            form.validate()
            for field in form:
                setattr(user, field.short_name, field.data)
            db.session.commit()
            flash('User updated.', 'success')
        except SQLAlchemyError as err:
            log.error(str(err))
            db.session.rollback()
            flash('Database: %s' % err.orig, 'error')

        return redirect(url_for('show_profile'))

    return render('profile.html', title='Profile Page', form=form)


@app.route('/upload', methods=('GET', 'POST'))
def upload_file():
    if request.method == 'POST':
        files = request.files.getlist('files[]')
        for f in files:
            # double check for errors that made it thru javascript gauntlet:
            filename = secure_filename(f.filename)
            if filename == '':
                flash('No files selected.', 'error')
                return redirect(request.url)


            if splitext(filename)[1][1:] in UPLOAD_UNSAVORY_EXTS: