Here are the examples of the python api sqlalchemy.engine_from_config taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
111 Examples
4
Example 1
def create_engine(db_name, settings, prefix='sqlalchemy.', scoped=False):
engine = engine_from_config(settings, prefix)
DBSession = SessionFactory.register(db_name, scoped)
DBSession.configure(bind=engine)
Database.get(db_name).metadata.bind = engine
return engine
3
Example 2
Project: sqlalchemy-datatables Source File: __init__.py
def main(global_config, **settings):
"""Return a Pyramid WSGI application."""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.include('pyramid_jinja2')
config.add_route('home', '/')
config.add_route('data', '/data')
config.add_route('dt_19x', '/dt_19x')
config.add_route('dt_110x', '/dt_110x')
config.scan()
return config.make_wsgi_app()
3
Example 3
Project: pyramid_oauth2_provider Source File: create_client_credentials.py
def main(argv=sys.argv):
if len(argv) != 3:
usage(argv)
config_uri = argv[1]
section = argv[2]
setup_logging(config_uri)
settings = get_appsettings(config_uri, section)
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine, settings)
with transaction.manager:
id, secret = create_client()
print('client_id:', id)
print('client_secret:', secret)
3
Example 4
Project: kcsrv Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(config.get_section(config.config_ini_section), prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(connection=connection, target_metadata=target_metadata, compare_type=True)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
3
Example 5
@classmethod
def setUpClass(cls):
""" must add default route 'home' and include apex
we also must create a default user/pass/group to test
"""
cls.engine = engine_from_config(settings, prefix='sqlalchemy.')
DBSession.configure(bind=cls.engine)
Base.metadata.create_all(cls.engine)
3
Example 6
Project: learning-python Source File: initializedb.py
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
model = MyModel(name='one', value=1)
DBSession.add(model)
3
Example 7
def initialize_db(dbconnection):
alembic_cfg = Config(DEFAULT_ALEMBIC_INI_PATH)
db = alembic_cfg.get_main_option("sqlalchemy.url", dbconnection)
alembic_cfg.set_main_option("sqlalchemy.url", db)
engine = sa.engine_from_config(
alembic_cfg.get_section(alembic_cfg.config_ini_section),
prefix='sqlalchemy.')
node.create_tables(engine)
groups.create_tables(engine)
public.create_tables(engine)
xfeatures.create_tables(engine)
quotaholder_serials.create_tables(engine)
# then, load the Alembic configuration and generate the
# version table, "stamping" it with the most recent rev:
command.stamp(alembic_cfg, "head")
3
Example 8
Project: coilmq Source File: __init__.py
def make_sa():
"""
Factory to creates a SQLAlchemy queue store, pulling config values from the CoilMQ configuration.
"""
configuration = dict(config.items('coilmq'))
engine = engine_from_config(configuration, 'qstore.sqlalchemy.')
init_model(engine)
store = SAQueue()
return store
3
Example 9
Project: python-social-auth Source File: initializedb.py
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
init_social(SOCIAL_AUTH_SETTINGS, Base, DBSession)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
3
Example 10
Project: taskflow Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = config.attributes.get('connection', None)
if connectable is None:
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.', poolclass=pool.NullPool)
with connectable.connect() as connection:
context.configure(connection=connection,
target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
3
Example 11
@classmethod
def configure(cls, settings):
kwargs = super(SQLCache, cls).configure(settings)
engine = engine_from_config(settings, prefix='db.')
# Create SQL schema if not exists
create_schema(engine)
kwargs['dbmaker'] = sessionmaker(bind=engine,
extension=ZopeTransactionExtension())
return kwargs
3
Example 12
Project: pyramid_scheduler Source File: test.py
def ReflectorApp(settings={}):
engine = sa.engine_from_config(settings, 'sqlalchemy.')
config = Configurator(settings=settings)
def reflect_params(request):
return Response(json.dumps(dict(request.params)))
def deferred_store_params(request):
request.registry.scheduler.add_date_job(
store_some_data, time.time() + 0.5, kwargs=dict(request.params))
return Response('ok')
config.add_route('reflect', '/reflect/*path')
config.add_view(reflect_params, route_name='reflect')
config.add_route('deferred', '/store/*path')
config.add_view(deferred_store_params, route_name='deferred')
return config.make_wsgi_app()
3
Example 13
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('newlunch', '/newlunch')
config.scan()
return config.make_wsgi_app()
3
Example 14
Project: learning-python Source File: __init__.py
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.include('pyramid_mako')
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
3
Example 15
Project: pyramid_oauth2_provider Source File: initializedb.py
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
3
Example 16
Project: bodhi Source File: signed.py
def __init__(self, hub, *args, **kwargs):
config_uri = '/etc/bodhi/production.ini'
self.settings = get_appsettings(config_uri)
engine = engine_from_config(self.settings, 'sqlalchemy.')
Base.metadata.create_all(engine)
self.db_factory = transactional_session_maker(engine)
prefix = hub.config.get('topic_prefix')
env = hub.config.get('environment')
self.topic = [
prefix + '.' + env + '.buildsys.tag'
]
super(SignedHandler, self).__init__(hub, *args, **kwargs)
log.info('Bodhi signed handler listening on:\n'
'%s' % pprint.pformat(self.topic))
3
Example 17
Project: bodhi Source File: approve_testing.py
def _get_db_session(config_uri):
"""
Construct and return a database session using settings from the given config_uri.
:param config_uri: A path to a config file to use to get the db settings.
:type config_uri: basestring
:return: A database session
"""
# There are many blocks of code like this in the codebase. We should consolidate them into a
# single utility function as described in https://github.com/fedora-infra/bodhi/issues/1028
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, 'sqlalchemy.')
Session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Session.configure(bind=engine)
return Session()
3
Example 18
Project: coilmq Source File: test_basic_sa.py
def _queuemanager(self):
"""
Returns the configured L{QueueManager} instance to use.
"""
data_dir = os.path.join(os.getcwd(), 'data')
if not os.path.exists(data_dir):
os.makedirs(data_dir)
configuration = {'qstore.sqlalchemy.url': 'sqlite:///data/coilmq.db'}
engine = engine_from_config(configuration, 'qstore.sqlalchemy.')
init_model(engine, drop=True)
store = SAQueue()
return QueueManager(store=store,
subscriber_scheduler=FavorReliableSubscriberScheduler(),
queue_scheduler=RandomQueueScheduler())
3
Example 19
Project: simple-settings Source File: database_reader.py
def __init__(self, database_config):
self.db = engine_from_config(database_config)
self.session = sessionmaker(bind=self.db)()
Base.metadata.create_all(self.db)
3
Example 20
Project: spendb Source File: env.py
def run_migrations_online():
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
3
Example 21
Project: pyramid_celery Source File: __init__.py
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
config = Configurator(settings=settings)
config.configure_celery(global_config['__file__'])
config.add_route('index', '/')
config.add_route('add_task', '/add_task')
config.add_route('delete_task', '/delete_task/{task_pk}')
config.scan()
return config.make_wsgi_app()
3
Example 22
Project: pypicloud Source File: sql.py
@classmethod
def configure(cls, settings):
kwargs = super(SQLAccessBackend, cls).configure(settings)
engine = engine_from_config(settings, prefix='auth.db.')
kwargs['dbmaker'] = sessionmaker(
bind=engine, extension=ZopeTransactionExtension())
# Create SQL schema if not exists
Base.metadata.create_all(bind=engine)
return kwargs
3
Example 23
Project: suma Source File: initializedb.py
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri, 'main')
engine = engine_from_config(settings, 'sqlalchemy.')
dbsession = create_dbsession(engine)
Base.metadata.create_all(engine)
alembic_cfg = Config(config_uri)
command.stamp(alembic_cfg, "head")
3
Example 24
Project: raptorizemw Source File: __init__.py
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
config = Configurator(settings=settings)
config.add_static_view('static', 'pyramidraptorized:static', cache_max_age=3600)
config.add_route('home', '/')
config.add_view('pyramidraptorized.views.my_view',
route_name='home',
renderer='templates/mytemplate.pt')
app = config.make_wsgi_app()
app = raptorizemw.make_middleware(app)
return app
3
Example 25
def includeme(config):
"""'Convenience method to initialise all components of this
:mod:`pyramid_sqlalchemy` package from a pyramid applicaiton.
"""
config.add_directive('enable_sql_two_phase_commit', enable_sql_two_phase_commit)
engine = engine_from_config(config.registry.settings, 'sqlalchemy.')
init_sqlalchemy(engine)
3
Example 26
Project: sqlalchemy Source File: test_parseconnect.py
def test_engine_from_config(self):
dbapi = mock_dbapi
config = {
'sqlalchemy.url': 'postgresql://scott:tiger@somehost/test'
'?fooz=somevalue',
'sqlalchemy.pool_recycle': '50',
'sqlalchemy.echo': 'true'}
e = engine_from_config(config, module=dbapi, _initialize=False)
assert e.pool._recycle == 50
assert e.url \
== url.make_url('postgresql://scott:tiger@somehost/test?foo'
'z=somevalue')
assert e.echo is True
3
Example 27
def initialize_sql(settings):
"""Called by the app on startup to setup bindings to the DB"""
engine = engine_from_config(settings, 'sqlalchemy.')
if not DBSession.registry.has():
DBSession.configure(bind=engine)
Base.metadata.bind = engine
import bookie.models.fulltext as ft
ft.set_index(settings.get('fulltext.engine'),
settings.get('fulltext.index'))
# setup the User relation, we've got import race conditions, ugh
from bookie.models.auth import User
if not hasattr(Bmark, 'user'):
Bmark.user = relation(User,
backref="bmark")
3
Example 28
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
3
Example 29
Project: KaraKara Source File: __init__.py
def init_DBSession(settings):
"""
To be called from Pyramid __init__ to setup SQLA from settings
This binds inits DBSession and Base
To be called AFTER all extentisons to Base have been imported/setup
Import the files with your datamodel, before calling this.
Upon this call is the SQLa tables are build/linked
"""
global engine
log.info("Bind DBSession to engine")
from sqlalchemy import engine_from_config
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
3
Example 30
Project: sqlalchemy Source File: test_parseconnect.py
def test_pool_threadlocal_from_config(self):
dbapi = mock_dbapi
config = {
'sqlalchemy.url': 'postgresql://scott:tiger@somehost/test',
'sqlalchemy.pool_threadlocal': "false"}
e = engine_from_config(config, module=dbapi, _initialize=False)
eq_(e.pool._use_threadlocal, False)
config = {
'sqlalchemy.url': 'postgresql://scott:tiger@somehost/test',
'sqlalchemy.pool_threadlocal': "true"}
e = engine_from_config(config, module=dbapi, _initialize=False)
eq_(e.pool._use_threadlocal, True)
3
Example 31
def _queuestore(self):
"""
Returns the configured L{QueueStore} instance to use.
Can be overridden by subclasses that wish to change out any queue store parameters.
@rtype: L{QueueStore}
"""
data_dir = os.path.join(os.getcwd(), 'data')
if not os.path.exists(data_dir):
os.makedirs(data_dir)
configuration = {'qstore.sqlalchemy.url': 'sqlite:///data/coilmq.db'}
engine = engine_from_config(configuration, 'qstore.sqlalchemy.')
init_model(engine, drop=True)
return SAQueue()
3
Example 32
Project: pyramid_celery Source File: populate.py
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
model = TaskItem(task='create more tasks!')
DBSession.add(model)
3
Example 33
Project: backfeed-protocol Source File: utils.py
def setup_database(
settings={
'sqlalchemy.url': 'sqlite:///:memory:',
}):
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
3
Example 34
Project: sqlalchemy Source File: test_parseconnect.py
def test_pool_reset_on_return_from_config(self):
dbapi = mock_dbapi
for value, expected in [
("rollback", pool.reset_rollback),
("commit", pool.reset_commit),
("none", pool.reset_none)
]:
config = {
'sqlalchemy.url': 'postgresql://scott:tiger@somehost/test',
'sqlalchemy.pool_reset_on_return': value}
e = engine_from_config(config, module=dbapi, _initialize=False)
eq_(e.pool._reset_on_return, expected)
0
Example 35
Project: lux Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# for the direct-to-DB use case, start a transaction on all
# engines, then run all migrations, then commit all transactions.
engines = {}
for name in re.split(r',\s*', db_names):
engines[name] = rec = {}
rec['engine'] = engine_from_config(
context.config.get_section(name),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
for name, rec in engines.items():
engine = rec['engine']
rec['connection'] = conn = engine.connect()
if USE_TWOPHASE:
rec['transaction'] = conn.begin_twophase()
else:
rec['transaction'] = conn.begin()
try:
for name, rec in engines.items():
logger.info("Migrating database %s" % name)
context.configure(
connection=rec['connection'],
upgrade_token="%s_upgrades" % name,
downgrade_token="%s_downgrades" % name,
target_metadata=target_metadata.get(name)
)
context.run_migrations(engine_name=name)
if USE_TWOPHASE:
for rec in engines.values():
rec['transaction'].prepare()
for rec in engines.values():
rec['transaction'].commit()
except:
for rec in engines.values():
rec['transaction'].rollback()
raise
finally:
for rec in engines.values():
rec['connection'].close()
0
Example 36
Project: rentmybikes Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 37
Project: puffin Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.readthedocs.org/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
engine = engine_from_config(config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 38
Project: pgcontents Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata,
include_schemas=True,
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 39
Project: sflvault Source File: server.py
def start_sqlalchemy(self):
self.engine = engine_from_config(SFLvaultServer.settings,
'sqlalchemy.')
0
Example 40
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(SECTION),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata,
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 41
Project: ansible-report Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 42
Project: PyClassLessons Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(connection=connection,
target_metadata=target_metadata,
**current_app.extensions['migrate'].configure_args)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 43
Project: baruwa2 Source File: environment.py
def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
config = PylonsConfig()
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# setup themes
template_paths = [os.path.join(root, 'templates')]
themesbase = app_conf.get('baruwa.themes.base', None)
if themesbase and os.path.isabs(themesbase):
templatedir = os.path.join(themesbase, 'templates')
if os.path.isdir(templatedir):
template_paths.append(templatedir)
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
static_files=os.path.join(root, 'public'),
templates=template_paths)
# Initialize config with the basic options
config.init_app(global_conf, app_conf, package='baruwa', paths=paths)
config['routes.map'] = make_map(config)
config['pylons.app_globals'] = app_globals.Globals(config)
config['pylons.h'] = baruwa.lib.helpers
# Setup cache object as early as possible
import pylons
pylons.cache._push_object(config['pylons.app_globals'].cache)
# Create the Mako TemplateLookup, with the default auto-escaping
config['pylons.app_globals'].mako_lookup = TemplateLookup(
directories=paths['templates'],
error_handler=handle_mako_error,
module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
input_encoding='utf-8', default_filters=['escape'],
imports=['from webhelpers.html import escape'])
# Setup the SQLAlchemy database engine
surl = config['sqlalchemy.url']
if surl.startswith('mysql'):
conv = conversions.copy()
conv[246] = float
engine = create_engine(surl, pool_recycle=1800,
connect_args=dict(conv=conv))
else:
engine = engine_from_config(config, 'sqlalchemy.', poolclass=NullPool)
init_model(engine)
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
return config
0
Example 44
Project: raggregate Source File: __init__.py
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.scan('raggregate.models')
engine = engine_from_config(settings, 'sqlalchemy.')
sqlahelper.add_engine(engine)
initialize_sql(engine)
session_factory = pyramid_beaker.session_factory_from_settings(settings)
template_static_asset = "{0}/static".format(settings['mako.directories'])
settings['template_static_asset'] = template_static_asset
config = Configurator(settings=settings)
config.include('pyramid_tm')
if 'solr.address' in settings:
import sunburnt
solr_conn = sunburnt.SolrInterface(settings['solr.address'])
config.registry.solr_conn = solr_conn
if 'twitter.app_key' in settings and 'twitter.app_secret' in settings:
from twython import Twython
app_twit = Twython(settings['twitter.app_key'],
settings['twitter.app_secret'])
config.registry.app_twit = app_twit
config.set_session_factory(session_factory)
# @TODO: the name "mako.directories" implies this could be a list
# right now we don't care. Someone should fix this.
config.add_static_view('static', template_static_asset)
config.add_static_view('user_imgs', settings['user.picture_upload_package'])
config.add_static_view('section_imgs', settings['section.picture_upload_package'])
config.add_route('home', '/')
config.add_route('login', '/login')
config.add_route('list', '/list')
config.add_route('post', '/post')
config.add_route('new_page', '/new_page')
config.add_route('new_post', '/new_post')
config.add_route('ban', '/ban')
config.add_route('vote', '/vote/{way}')
config.add_route('full', '/full/{sub_id}')
config.add_route('epistle', '/messages/{box}')
config.add_route('follow', '/follow')
config.add_route('save', '/save')
config.add_route('notify', '/notify')
config.add_route('search', '/search')
config.add_route('twit_sign', '/twit_sign')
config.add_route('user_info', '/user_info')
config.add_route('user_preferences', '/user_preferences')
config.add_route('buttons', '/buttons')
config.add_route('favicon', '/favicon.ico')
config.add_route('atom_story', '/atom_story.xml')
config.add_route('atom_self_story', '/atom_self_story.xml')
config.add_route('atom_combined', '/atom_combined.xml')
config.add_route('atom_comment', '/atom_comment.xml')
config.add_route('section', '/section')
config.add_route('motd', '/motd')
config.add_route('sublist', '/sublist/{sub_title}')
config.add_route('sublistc', '/sublist_create')
config.add_route('lost_password', '/lost_password')
config.add_subscriber(subscribers.ban, NewResponse)
config.add_subscriber(subscribers.user_session_handler, BeforeRender)
config.add_subscriber(subscribers.clear_per_request_session, NewRequest)
config.add_subscriber(subscribers.clean_inputs, NewRequest)
config.scan('raggregate.views')
pyramid_beaker.set_cache_regions_from_settings(settings)
return config.make_wsgi_app()
0
Example 45
Project: pylons Source File: environment_def_sqlamodel.py
def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
config = PylonsConfig()
# 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='projectname', paths=paths)
config['routes.map'] = make_map(config)
config['pylons.app_globals'] = app_globals.Globals(config)
config['pylons.h'] = projectname.lib.helpers
# Setup cache object as early as possible
import pylons
pylons.cache._push_object(config['pylons.app_globals'].cache)
# Create the Mako TemplateLookup, with the default auto-escaping
config['pylons.app_globals'].mako_lookup = TemplateLookup(
directories=paths['templates'],
error_handler=handle_mako_error,
module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
input_encoding='utf-8', default_filters=['escape'],
imports=['from webhelpers.html import escape'])
# Create the Genshi TemplateLoader
config['pylons.app_globals'].genshi_loader = TemplateLoader(
paths['templates'], auto_reload=True)
# Create the Jinja2 Environment
config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader(
[FileSystemLoader(path) for path in paths['templates']]))
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
engine = engine_from_config(config, 'sqlalchemy.')
init_model(engine)
return config
0
Example 46
Project: CDDA-Game-Launcher Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
0
Example 47
Project: sqlalchemy-datatables Source File: initializedb.py
def main(argv=sys.argv):
"""Populate database with 30 users."""
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
i = 0
while i < 30:
address = Address(description='Address#2' + str(i).rjust(2, "0"))
DBSession.add(address)
user = User(name='User#1' + str(i).rjust(2, "0"))
user.address = address
DBSession.add(user)
sleep(1)
i += 1
0
Example 48
Project: Flask-PostgreSQL-API-Seed Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 49
Project: june Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool
)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
0
Example 50
Project: rootio_web Source File: env.py
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata,
compare_type=True
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()