Esempio n. 1
0
def create_and_setup_app(package_name, package_path=None,
                         settings_override=None,
                         register_security_blueprint=True):
    """
    Return a :class:`Flask` application instance configured with common
    functionality.

    :param str package_name: application package name
    :param str package_path: application package path
    :param dict settings_override: a dictionary of settings to override
    """
    app = create_app(package_name, package_path)

    db.init_app(app)
    mail.init_app(app)
    security.init_app(app, SQLAlchemyUserDatastore(db, User, Role),
                      register_blueprint=register_security_blueprint)

    if package_path:
        register_blueprints(app, package_name, package_path)

    # After request
    if not app.after_request_funcs.get(None):
        app.after_request_funcs[None] = []
    app.after_request_funcs[None].append(call_after_request_callbacks)

    return app
Esempio n. 2
0
def create_app(environment_name):
    app = Flask(__name__)
    app.config.from_object(config[environment_name])
    register_err_handlers(app)

    db.init_app(app)
    bootstrap.init_app(app)
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security.init_app(app, datastore=user_datastore)

    from app.admin import admin as admin_bp
    from app.front import front as front_bp

    app.register_blueprint(admin_bp)
    app.register_blueprint(front_bp)


    return app
Esempio n. 3
0
from os import path
from flask import Flask
from flask_security import current_user
from flask_session import Session
from app.core import db, security, mail

import app.models as models_sounds
from .site import mod_site
import app.admin.models_security as models_security
from .admin import mod_admin

app = Flask(__name__, static_folder='static')
app.config.from_pyfile('config.py')

Session(app)
mail.init_app(app)

db.init_app(app)
db.create_all(app=app)  # app=app weil sonst applicationbound error

security.init_app(app, models_security.user_datastore)

app.register_blueprint(mod_admin, url_prefix='/admin')
app.register_blueprint(mod_site)

app.jinja_env.globals.update(config=app.config)
app.jinja_env.globals.update(current_user=current_user)
app.jinja_env.globals.update(path=path)

# seed_security()