def get_archive(): app = current_app._get_current_object() if not hasattr(app, '_aleph_archive'): app._aleph_archive = archive.from_config(app.config) return app._aleph_archive
db = SQLAlchemy(app) migrate = Migrate(app, db, directory=app.config.get('ALEMBIC_DIR')) es = Elasticsearch(app.config.get('ELASTICSEARCH_URL'), timeout=120) es_index = app.config.get('ELASTICSEARCH_INDEX', app_name) queue_name = app_name + '_q' app.config['CELERY_DEFAULT_QUEUE'] = queue_name app.config['CELERY_QUEUES'] = ( Queue(queue_name, Exchange(queue_name), routing_key=queue_name), ) celery = Celery(app_name, broker=app.config['CELERY_BROKER_URL']) celery.config_from_object(app.config) assets = Environment(app) archive = archive.from_config(app.config) if not app.debug and app.config.get('MAIL_ADMINS'): credentials = app.config.get('MAIL_CREDENTIALS', ()) mail_handler = SMTPHandler(app.config.get('MAIL_HOST'), app.config.get('MAIL_FROM'), app.config.get('MAIL_ADMINS'), '[%s] Crash report' % app_name, credentials=credentials, secure=()) mail_handler.setLevel(logging.ERROR) app.logger.addHandler(mail_handler) def system_role(role_name): from aleph.model import Role