def get_config(confpath): HERE = os.path.abspath(os.path.dirname(__file__)) CONFD_PATH = os.path.join(HERE, confpath) from rhaptos2.common.configuration import ( find_configuration_file, Configuration, ) config = Configuration.from_file(CONFD_PATH) backend.initdb(config) return config
def make_app(config): """Application factory""" app = Flask(__name__) app.config.update(config) set_up_logging(app) # Set the application app = set_app(app) print config backend.initdb(config) # Initialize the views from rhaptos2.user import views return app
from rhaptos2.user import backend, usermodel from rhaptos2.user.backend import db_session import os ### This probably not best instantiated here. But nose not easy to work around HERE = os.path.abspath(os.path.dirname(__file__)) CONFD_PATH = os.path.join(HERE, "../../local.ini") from rhaptos2.user.configuration import ( find_configuration_file, Configuration, ) config = Configuration.from_file(CONFD_PATH) backend.initdb(config) #only do thios once per applicaiton not per test ############### admin tools for nose def setup(): clean_dbase() populate_dbase() def teardown(): backend.db_session.remove() def clean_dbase(): conn = psycopg2.connect("""dbname='%(pgdbname)s'\ user='******' \ host='%(pghost)s' \ password='******'""" % config);
### import os from rhaptos2.user import backend, usermodel, conf from rhaptos2.user.backend import db_session HERE = os.path.abspath(os.path.dirname(__file__)) CONFD_PATH = os.path.join(HERE, "../../local.ini") confd = conf.get_config(CONFD_PATH) from rhaptos2.user.configuration import ( find_configuration_file, Configuration, ) config = Configuration.from_file(CONFD_PATH) backend.initdb(config) print "Connecting to Database:" print config['pghost'] print "You are now in shell, without access to Flask App, but with dbase" print "You may want to review prepopulate.py for notes on prepopulating the dbase during development"