def register_extensions(app):
    from application.assets import env
    env.init_app(app)

    from flask.ext.mongoengine import MongoEngine
    MongoEngine().init_app(app)

    # flask security setup
    from application.extensions import user_datastore
    Security(app, user_datastore)

    # flask markdown
    from flaskext.markdown import Markdown
    Markdown(app)

    from application.extensions import mail
    mail.init_app(app)

    import os
    if 'SENTRY_DSN' in os.environ:
        from raven.contrib.flask import Sentry
        Sentry(app, dsn=os.environ['SENTRY_DSN'])

    from application.sso.oidc import OIDC
    app.oidc_client = OIDC(app)

    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension().init_app(app)
Example #2
0
def register_extensions(app):
    from application.assets import env
    env.init_app(app)

    from flask.ext.mongoengine import MongoEngine
    MongoEngine().init_app(app)

    # flask security setup
    from application.extensions import user_datastore
    Security(app, user_datastore)

    # flask markdown
    from flaskext.markdown import Markdown
    Markdown(app)

    from application.extensions import mail
    mail.init_app(app)

    import os
    if 'SENTRY_DSN' in os.environ:
        from raven.contrib.flask import Sentry
        Sentry(app, dsn=os.environ['SENTRY_DSN'])

    from application.sso.oidc import OIDC
    app.oidc_client = OIDC(app)

    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension().init_app(app)
def register_extensions(app):
    from application.assets import env
    env.init_app(app)

    from application.models import db
    db.init_app(app)

    # flask security setup
    from application.extensions import user_datastore
    Security(app, user_datastore)

    # flask markdown
    from flaskext.markdown import Markdown
    Markdown(app)

    # flask mail
    from application.extensions import mail
    mail.init_app(app)

    import os
    if 'SENTRY_DSN' in os.environ:
        from raven.contrib.flask import Sentry
        Sentry(app, dsn=os.environ['SENTRY_DSN'])

    from application.sso.oidc import OIDC
    app.oidc_client = OIDC(app)
Example #4
0
def register_extensions(app):
    if app.config.get('ELASTICSEARCH_SUPPORT', False):
        es.init_app(app)
    mail.init_app(app)
    redis.init_app(app)

    login_manager.session_protection = 'strong'
    login_manager.login_view = '/admin/login'
    login_manager.init_app(app)
    """init redis connection"""
    redisco.connection_setup(host=app.config['REDIS_CONFIG']['HOST'],
                             port=app.config['REDIS_CONFIG']['PORT'],
                             db=app.config['REDIS_CONFIG']['DB'])

    def filter_func(kv):
        print(kv)

    app.jinja_env.add_extension('pyjade.ext.jinja.PyJadeExtension')
    from application.services.theme import RedisLoader
    app.jinja_env.loader = RedisLoader()

    from pyjade import Compiler
    Compiler.register_autoclosecode('load')

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects.get_by_id(user_id)

    if not app.config['DEBUG'] and not app.config['TESTING']:
        sentry.init_app(
            app,
            dsn=
            'https://*****:*****@app.getsentry.com/93431'
        )
Example #5
0
File: app.py Project: 8dspaces/wiwi
def configure_extensions(app):
    # flask-MongoEngine
    db.init_app(app)
    db.register_connection(**app.config.get('ORDER_DB_CONFIG'))
    db.register_connection(**app.config.get('INVENTORY_DB_CONFIG'))
    db.register_connection(**app.config.get('CART_DB_CONFIG'))
    db.register_connection(**app.config.get('CONTENT_DB_CONFIG'))
    db.register_connection(**app.config.get('LOG_DB_CONFIG'))

    mongo_inventory.init_app(app, config_prefix='MONGO_INVENTORY')

    redis.connection_pool = ConnectionPool(**app.config.get('REDIS_CONFIG'))
    session_redis.connection_pool = ConnectionPool(
        **app.config.get('SESSION_REDIS'))

    # server side session
    app.session_interface = RedisSessionInterface(session_redis)

    # flask-mail
    mail.init_app(app)
    mail.app = app

    # flask-cache
    cache.init_app(app)

    # flask-bcrypt
    bcrypt.init_app(app)

    # flask-babel
    babel.init_app(app)

    # flask-assets
    assets.init_app(app)

    # flask_debugtoolbar
    toolbar.init_app(app)

    # flask-login (not configured will raise 401 error)
    login_manager.login_view = 'frontend.login'
    # login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(id):
        import application.models as Models
        return Models.User.objects(id=id, is_deleted=False).first()

    login_manager.init_app(app)
    login_manager.login_message = _('Please log in to access this page.')
    login_manager.needs_refresh_message = _(
        'Please reauthenticate to access this page.')

    # flask-principal (must be configed after flask-login!!!)
    principal.init_app(app)

    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        principal_on_identity_loaded(sender, identity)
Example #6
0
def create_app(config_class=config.DevelopmentConfig):
    app = Flask(__name__)  
    app.config.from_object(config_class) 
    db.init_app(app)
    migrate.init_app(app, db)
    login.init_app(app) 
    app.redis = Redis.from_url(app.config['REDIS_URL'])
    app.task_queue = rq.Queue('securenotesapp-tasks', connection=app.redis)
    mail.init_app(app)

    from application.routes.errors import bp as errors_bp
    app.register_blueprint(errors_bp)

    from application.routes.auth import bp as auth_bp
    app.register_blueprint(auth_bp)

    from application.routes.main import bp as main_bp
    app.register_blueprint(main_bp)

    from application.routes.notes import bp as notes_bp
    app.register_blueprint(notes_bp)

    from application.routes.admin import bp as admin_bp
    app.register_blueprint(admin_bp)

    if not app.debug and not app.testing:
        if app.config['LOG_TO_STDOUT']:
            stream_handler = logging.StreamHandler()
            stream_handler.setLevel(logging.INFO)
            app.logger.addHandler(stream_handler)
        else:
            if not os.path.exists('logs'):
                os.mkdir('logs')
            file_handler = RotatingFileHandler('logs/noteapp.log',
                                               maxBytes=10240, backupCount=10)
            file_handler.setFormatter(logging.Formatter(
                '%(asctime)s %(levelname)s: %(message)s '
                '[in %(pathname)s:%(lineno)d]'))
            file_handler.setLevel(logging.INFO)
            app.logger.addHandler(file_handler)

        app.logger.setLevel(logging.INFO)
        app.logger.info('Noteapp startup')

    from application.models.user import User
    from application.models.note import Note
    from application.models.post import Post

    @app.shell_context_processor
    def make_shell_context():
        return {'db': db, 'User': User, 'Post': Post, 'Note': Note}

    return app
Example #7
0
def register_extensions(app):
    from application.extensions import db
    from application.extensions import login
    from application.extensions import migrate
    from application.extensions import mail
    from application.extensions import babel
    from application.extensions import csrf

    csrf._exempt_views.add('dash.dash.dispatch')

    db.init_app(app)
    login.init_app(app)
    login.login_view = "auth.login"
    migrate.init_app(app, db)
    mail.init_app(app)
    babel.init_app(app)
    csrf.init_app(app)
Example #8
0
def configure_extensions(app):
    """Configures the extensions."""
    # Flask-BabelEx
    babel.init_app(app)

    # Captcha Solver
    captcha_solver.init_app(app)

    # Flask-Mail
    mail.init_app(app)

    # Flask-Admin
    admin.init_app(app)

    # Flask-Mongo Engine
    db.init_app(app)

    ma.init_app(app)
    # Flask-Cache
    cache.init_app(app,
                   config={
                       'CACHE_TYPE': 'redis',
                       'CACHE_KEY_PREFIX': 'UHE',
                       'CACHE_REDIS_URL': app.config['REDIS_URL']
                   })

    print(app.testing)
    # Flask-And-Redis
    # jwt.secret_key = app.config['SECRET_KEY']
    redis_store.init_app(app)

    # Flask-Limiter
    limiter.init_app(app)

    # Flask-Allows
    allows.init_app(app)
    allows.identity_loader(lambda: current_user)
    login_manager.init_app(app)
    # Flask-Plugins
    app.school_time = Time()

    oauth.init_app(app)

    dashboard.bind(app)