def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='fivecents', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = fivecents.lib.helpers # Jinja2 configuration config['pylons.g'].jinja_env = Environment(loader=PackageLoader('fivecents', 'templates'), extensions=['jinja2.ext.i18n']) # Jinja's unable to request c's attributes without strict_c config['pylons.strict_c'] = True init_model(engine_from_config(config, 'sqlalchemy.'))
def setUp(self): super(DbTestCase, self).setUp() from paste.deploy.loadwsgi import appconfig self.config = appconfig("config:test.ini", relative_to=conf_dir) from sqlalchemy import engine_from_config from fivecents.model import init_model, model_instance init_model(bind=engine_from_config(self.config, "sqlalchemy.")) self.model = model_instance() self.connection = self.model.engine.connect() self.db = self.model.session