def app_context(config_filename): """Provide a context in which the application is available with the specified configuration. """ app = create_app(config_filename) with app.app_context(): yield app
def app_context(config_name): """Provide a context in which the application is available with the specified environment. """ app = create_app(config_name) with app.app_context(): yield app
def setUp(self, config_filename=CONFIG_FILENAME_TEST_PARTY): self.app = create_app(config_filename) # Allow overriding of database URI from the environment. db_uri_override = os.environ.get('DATABASE_URI') if db_uri_override: self.app.config['SQLALCHEMY_DATABASE_URI'] = db_uri_override self.db = db db.app = self.app set_up_database(db)
def setUp(self, config_filename=CONFIG_FILENAME_TEST): self.app = create_app(config_filename) # Allow overriding of database URI from the environment. db_uri_override = os.environ.get('DATABASE_URI') if db_uri_override: self.app.config['SQLALCHEMY_DATABASE_URI'] = db_uri_override self.db = db db.app = self.app db.reflect() db.drop_all() db.create_all() self.create_brand_and_party() self.create_admin()
def setUp(self, env='test'): self.app = create_app(env) # Allow overriding of database URI from the environment. db_uri_override = os.environ.get('DATABASE_URI') if db_uri_override: self.app.config['SQLALCHEMY_DATABASE_URI'] = db_uri_override self.db = db db.app = self.app db.reflect() db.drop_all() db.create_all() self.create_brand_and_party() self.create_admin()
def app_context(*, config_filename=CONFIG_FILENAME_TEST_PARTY): app = create_app(config_filename) with app.app_context(): yield app
def app_context(*, config_filename=CONFIG_FILENAME_TEST): app = create_app(config_filename) with app.app_context(): yield app
from werkzeug.wsgi import SharedDataMiddleware from byceps.application import create_app, init_app from byceps.blueprints.brand.models import Brand from byceps.blueprints.party.models import Party from byceps.blueprints.shop.models.article import Article from byceps.blueprints.shop.models.order import Order, OrderItem, \ PaymentState as OrderPaymentState from byceps.blueprints.user.models import User, UserDetail from byceps.database import db from byceps.util.system import get_config_env_name_from_env environment = get_config_env_name_from_env(default='development') app = create_app(environment) init_app(app) if app.debug: exports = { '/users/avatars': str(app.config['PATH_USER_AVATAR_IMAGES']), } path_content = app.config.get('PATH_CONTENT') if path_content: exports['/content'] = str(path_content) app.wsgi_app = SharedDataMiddleware(app.wsgi_app, exports) from flask_debugtoolbar import DebugToolbarExtension app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
#!/usr/bin/env python """Run a worker for the job queue. :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from rq import Worker from byceps.application import create_app from byceps.util.jobqueue import connection, get_queue from byceps.util.system import get_config_filename_from_env_or_exit if __name__ == '__main__': config_filename = get_config_filename_from_env_or_exit() app = create_app(config_filename) with app.app_context(): with connection(): queues = [get_queue(app)] worker = Worker(queues) worker.work()
STATIC_URL_PREFIX_PARTY from byceps.database import db from byceps.services.brand.models import Brand from byceps.services.party.models import Party from byceps.services.shop.article.models import Article from byceps.services.shop.order.models import Order, OrderItem, \ PaymentState as OrderPaymentState from byceps.services.user.models.detail import UserDetail from byceps.services.user.models.user import User from byceps.services.user.service import find_user_by_screen_name from byceps.util.system import get_config_filename_from_env_or_exit config_filename = get_config_filename_from_env_or_exit() app = create_app(config_filename) init_app(app) def _assemble_exports(): exports = {} _export_path_if_configured(exports, 'PATH_GLOBAL', STATIC_URL_PREFIX_GLOBAL) _export_path_if_configured(exports, 'PATH_BRAND', STATIC_URL_PREFIX_BRAND) _export_path_if_configured(exports, 'PATH_PARTY', STATIC_URL_PREFIX_PARTY) return exports def _export_path_if_configured(exports, config_key, url_path): path = app.config.get(config_key)