def run(app=None): app = app or lso.create_app(__name__) with app.app_context(): if MonierEntry.query.count(): print 'Queries already exist. Drop the table first.' else: init_monier(app)
def app(request): override = { 'CACHE_TYPE': 'null', 'DATABASE_URI': 'sqlite://', 'MONIER_DIR': os.path.join(os.path.dirname(__file__), 'data', 'monier-williams'), 'SQLALCHEMY_DATABASE_URI': 'sqlite://', 'TESTING': True, 'WTF_CSRF_ENABLED': False, } app = lso.create_app(__name__, 'config', override) with app.app_context(): lso.database.db.create_all() ctx = app.app_context() ctx.push() def teardown(): ctx.pop() request.addfinalizer(teardown) return app
import importlib import lso.database from flask.ext.script import Manager, prompt_bool from lso import create_app import lso.texts.lib from sanskrit import Context app = create_app(__name__, 'config') manager = Manager(app) def _get_bp_setup(name): """Returns a reference to `lso.{name}.setup`""" return importlib.import_module('lso.%s.setup' % name) @manager.command def cache_clear(): """Clears the flask-cache cache.""" from lso import cache cache.clear() @manager.command def db_create_all(): """Creates all tables.""" lso.database.db.create_all()
import os import sys sys.path.append(os.path.dirname(__file__)) import production activate_this = os.path.join(production.virtualenv_path, 'bin/activate_this.py') execfile(activate_this, dict(__file__=activate_this)) from lso import create_app application = create_app(__name__, 'production')