Exemple #1
0
def configure_extensions(app, admin):
    babel.configure(app)
    generic.configure(app)
    Cache(app)
    Mail(app)
    Dealer(app)
    error_handlers.configure(app)
    db.init_app(app)
    fixtures.configure(app)
    themes.configure(app, db)  # Themes should be configured after db

    context_processors.configure(app)
    template_filters.configure(app)

    user_datastore = MongoEngineUserDatastore(db, User, Role)
    Security(app, user_datastore)

    blueprints.load_from_packages(app)
    blueprints.load_from_folder(app)

    configure_admin(app, admin)

    if app.config.get('DEBUG_TOOLBAR_ENABLED'):
        try:
            from flask_debugtoolbar import DebugToolbarExtension
            DebugToolbarExtension(app)
        except:
            pass

    before_request.configure(app)
    views.configure(app)

    return app
Exemple #2
0
    def test_flask(self):
        from flask import Flask, g
        from dealer.contrib.flask import Dealer

        app = Flask('test')
        Dealer(app)
        self.assertTrue(app.revision)
        app.route('/')(lambda: g.revision)
        with app.test_request_context():
            client = app.test_client()
            response = client.get('/')
            print response.data
            self.assertTrue(app.revision in response.data)
Exemple #3
0
def test_flask():
    from flask import Flask, g
    from dealer.contrib.flask import Dealer

    app = Flask('test')
    Dealer(app)
    assert app.revision

    app.route('/')(lambda: "%s - %s" % (g.revision, g.tag))
    with app.test_request_context():
        client = app.test_client()
        response = client.get('/')
        assert app.revision in response.data.decode('utf-8')
        assert app.tag in response.data.decode('utf-8')
Exemple #4
0
def configure_extensions(app, admin):
    cache.init_app(app)
    babel.configure(app)
    generic.configure(app)
    Mail(app)
    Dealer(app)
    error_handlers.configure(app)
    db.init_app(app)

    themes.configure(app, db)  # Themes should be configured after db

    context_processors.configure(app)
    template_filters.configure(app)

    app.security = Security(app, MongoEngineUserDatastore(db, User, Role))

    fixtures.configure(app, db)
    blueprints.load_from_packages(app)
    blueprints.load_from_folder(app)

    # enable .pdf support for posts
    weasyprint.configure(app)

    configure_admin(app, admin)

    if app.config.get('DEBUG_TOOLBAR_ENABLED'):
        try:
            from flask_debugtoolbar import DebugToolbarExtension
            DebugToolbarExtension(app)
        except:
            pass

    before_request.configure(app)
    views.configure(app)

    oauthlib.configure(app)

    if app.config.get('SENTRY_ENABLED', False):
        from .sentry import configure
        configure(app)

    return app
Exemple #5
0
from flask import request
from flask_collect import Collect
from flask_debugtoolbar import DebugToolbarExtension
from flask_mail import Mail
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from flaskext.babel import Babel
from flask_cache import Cache
from dealer.contrib.flask import Dealer

from .app import create_app

babel = Babel()
cache = Cache()
db = SQLAlchemy()
dealer = Dealer()
mail = Mail()

manager = Manager(create_app)
manager.add_option("-c", "--config", dest="config", required=False)

collect = Collect()
collect.init_script(manager)


def config_extensions(app):
    " Init application with extensions. "

    cache.init_app(app)
    collect.init_app(app)
    db.init_app(app)
Exemple #6
0
from dotenv import load_dotenv
import toml
import lib.base
import lib.talks
import lib.info_beamer

app = Flask(__name__)
load_dotenv()
config = dict()
config_file = toml.load(environ["CONFIG_FILE"])
for section in config_file.keys():
    for option in config_file[section]:
        config["_".join((section, option))] = config_file[section][option]
app.config.update(config)
scheduler = APScheduler(app=app)
Dealer(app)
redis_client = FlaskRedis(app)

if app.env == "development":
    print("Not enabling Sentry in development.")
    sentry = None
else:
    sentry = sentry_sdk.init(
        dsn=lib.base.read_secret("FFTALKS_SENTRY_DSN"),
        integrations=[FlaskIntegration()],
        release=app.revision,
    )


@app.context_processor
def inject_js_sentry_dsn():