Mercurial > kallithea
changeset 6214:f973b866fffc
Turbogears2 migration: use sqlalchemy.url iso sqlalchemy.db1.url
In Turbogears2, much of the application initialization is handled by the
framework, whereas in Pylons the application was responsible for it.
Initializing SQLAlchemy is one such part of initialization which is handled
by Turbogears2.
Turbogears2 expects the configuration file to refer to the database using
'sqlalchemy.url' rather than the current 'sqlalchemy.db1.url'. While the
exact name is not really important, not following this approach means we'll
need to override the sqlalchemy initialization method.
Therefore, as a preparation to the Turbogears2 migration, already change the
database reference string under Pylons.
When upgrading to a version of Kallithea containing this commit, the .ini
file will manually need to be adapted to remove the .db1 strings.
author | Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> |
---|---|
date | Mon, 22 Aug 2016 17:50:51 +0200 |
parents | 591effa1fc4d |
children | 5eec79420ce3 |
files | development.ini docs/upgrade.rst kallithea/alembic/env.py kallithea/bin/template.ini.mako kallithea/config/deployment.ini_tmpl kallithea/config/environment.py kallithea/lib/celerylib/__init__.py kallithea/lib/hooks.py kallithea/lib/paster_commands/common.py kallithea/lib/utils.py kallithea/tests/scripts/manual_test_concurrency.py kallithea/tests/test.ini kallithea/websetup.py scripts/dbmigrate-test scripts/generate-ini.py |
diffstat | 15 files changed, 34 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Mon Sep 12 17:41:20 2016 +0200 +++ b/development.ini Mon Aug 22 17:50:51 2016 +0200 @@ -484,18 +484,18 @@ ######################################################### # SQLITE [default] -sqlalchemy.db1.url = sqlite:///%(here)s/kallithea.db?timeout=60 +sqlalchemy.url = sqlite:///%(here)s/kallithea.db?timeout=60 # POSTGRESQL -#sqlalchemy.db1.url = postgresql://user:pass@localhost/kallithea +#sqlalchemy.url = postgresql://user:pass@localhost/kallithea # MySQL -#sqlalchemy.db1.url = mysql://user:pass@localhost/kallithea?charset=utf8 +#sqlalchemy.url = mysql://user:pass@localhost/kallithea?charset=utf8 # see sqlalchemy docs for others -sqlalchemy.db1.echo = false -sqlalchemy.db1.pool_recycle = 3600 +sqlalchemy.echo = false +sqlalchemy.pool_recycle = 3600 ################################ ### ALEMBIC CONFIGURATION ####
--- a/docs/upgrade.rst Mon Sep 12 17:41:20 2016 +0200 +++ b/docs/upgrade.rst Mon Aug 22 17:50:51 2016 +0200 @@ -54,7 +54,7 @@ If using MySQL, please consult the documentation for the ``mysqldump`` utility. -Look for ``sqlalchemy.db1.url`` in your configuration file to determine +Look for ``sqlalchemy.url`` in your configuration file to determine database type, settings, location, etc.
--- a/kallithea/alembic/env.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/alembic/env.py Mon Aug 22 17:50:51 2016 +0200 @@ -31,7 +31,7 @@ # [alembic] sqlalchemy.url. database_url = ( config.get_main_option('sqlalchemy.url') or - config.get_section_option('app:main', 'sqlalchemy.db1.url') + config.get_section_option('app:main', 'sqlalchemy.url') ) # Configure default logging for Alembic. (This can be overriden by the
--- a/kallithea/bin/template.ini.mako Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/bin/template.ini.mako Mon Aug 22 17:50:51 2016 +0200 @@ -484,21 +484,21 @@ %if database_engine == 'sqlite': # SQLITE [default] -sqlalchemy.db1.url = sqlite:///${here}/kallithea.db?timeout=60 +sqlalchemy.url = sqlite:///${here}/kallithea.db?timeout=60 %elif database_engine == 'postgres': # POSTGRESQL -sqlalchemy.db1.url = postgresql://user:pass@localhost/kallithea +sqlalchemy.url = postgresql://user:pass@localhost/kallithea %elif database_engine == 'mysql': # MySQL -sqlalchemy.db1.url = mysql://user:pass@localhost/kallithea?charset=utf8 +sqlalchemy.url = mysql://user:pass@localhost/kallithea?charset=utf8 %endif # see sqlalchemy docs for others -sqlalchemy.db1.echo = false -sqlalchemy.db1.pool_recycle = 3600 +sqlalchemy.echo = false +sqlalchemy.pool_recycle = 3600 <%text>################################</%text> <%text>### ALEMBIC CONFIGURATION ####</%text>
--- a/kallithea/config/deployment.ini_tmpl Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/config/deployment.ini_tmpl Mon Aug 22 17:50:51 2016 +0200 @@ -476,18 +476,18 @@ ######################################################### # SQLITE [default] -sqlalchemy.db1.url = sqlite:///%(here)s/kallithea.db?timeout=60 +sqlalchemy.url = sqlite:///%(here)s/kallithea.db?timeout=60 # POSTGRESQL -#sqlalchemy.db1.url = postgresql://user:pass@localhost/kallithea +#sqlalchemy.url = postgresql://user:pass@localhost/kallithea # MySQL -#sqlalchemy.db1.url = mysql://user:pass@localhost/kallithea?charset=utf8 +#sqlalchemy.url = mysql://user:pass@localhost/kallithea?charset=utf8 # see sqlalchemy docs for others -sqlalchemy.db1.echo = false -sqlalchemy.db1.pool_recycle = 3600 +sqlalchemy.echo = false +sqlalchemy.pool_recycle = 3600 ################################ ### ALEMBIC CONFIGURATION ####
--- a/kallithea/config/environment.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/config/environment.py Mon Aug 22 17:50:51 2016 +0200 @@ -93,7 +93,7 @@ test_index = not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)) if os.environ.get('TEST_DB'): # swap config if we pass enviroment variable - config['sqlalchemy.db1.url'] = os.environ.get('TEST_DB') + config['sqlalchemy.url'] = os.environ.get('TEST_DB') from kallithea.lib.utils import create_test_env, create_test_index from kallithea.tests import TESTS_TMP_PATH @@ -107,8 +107,8 @@ # MULTIPLE DB configs # Setup the SQLAlchemy database engine - sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') - init_model(sa_engine_db1) + sa_engine = engine_from_config(config, 'sqlalchemy.') + init_model(sa_engine) set_available_permissions(config) repos_path = make_ui('db').configitems('paths')[0][1]
--- a/kallithea/lib/celerylib/__init__.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/lib/celerylib/__init__.py Mon Aug 22 17:50:51 2016 +0200 @@ -122,7 +122,7 @@ def get_session(): if CELERY_ON: - engine = engine_from_config(config, 'sqlalchemy.db1.') + engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) sa = meta.Session() return sa
--- a/kallithea/lib/hooks.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/lib/hooks.py Mon Aug 22 17:50:51 2016 +0200 @@ -395,7 +395,7 @@ load_environment(conf.global_conf, conf.local_conf, test_env=False, test_index=False) - engine = engine_from_config(conf, 'sqlalchemy.db1.') + engine = engine_from_config(conf, 'sqlalchemy.') init_model(engine) baseui = make_ui('db')
--- a/kallithea/lib/paster_commands/common.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/lib/paster_commands/common.py Mon Aug 22 17:50:51 2016 +0200 @@ -103,5 +103,5 @@ from kallithea.model import init_model from kallithea.lib.utils2 import engine_from_config setup_cache_regions(config) - engine = engine_from_config(config, 'sqlalchemy.db1.') + engine = engine_from_config(config, 'sqlalchemy.') init_model(engine)
--- a/kallithea/lib/utils.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/lib/utils.py Mon Aug 22 17:50:51 2016 +0200 @@ -632,7 +632,7 @@ from kallithea.tests import HG_REPO, GIT_REPO, TESTS_TMP_PATH # PART ONE create db - dbconf = config['sqlalchemy.db1.url'] + dbconf = config['sqlalchemy.url'] log.debug('making test db %s', dbconf) # create test dir if it doesn't exist
--- a/kallithea/tests/scripts/manual_test_concurrency.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/tests/scripts/manual_test_concurrency.py Mon Aug 22 17:50:51 2016 +0200 @@ -82,7 +82,7 @@ def get_session(): - engine = engine_from_config(conf, 'sqlalchemy.db1.') + engine = engine_from_config(conf, 'sqlalchemy.') init_model(engine) sa = meta.Session return sa
--- a/kallithea/tests/test.ini Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/tests/test.ini Mon Aug 22 17:50:51 2016 +0200 @@ -488,19 +488,19 @@ ######################################################### # SQLITE [default] -#sqlalchemy.db1.url = sqlite:///%(here)s/kallithea.db?timeout=60 -sqlalchemy.db1.url = sqlite:///%(here)s/kallithea_test.sqlite +#sqlalchemy.url = sqlite:///%(here)s/kallithea.db?timeout=60 +sqlalchemy.url = sqlite:///%(here)s/kallithea_test.sqlite # POSTGRESQL -#sqlalchemy.db1.url = postgresql://user:pass@localhost/kallithea +#sqlalchemy.url = postgresql://user:pass@localhost/kallithea # MySQL -#sqlalchemy.db1.url = mysql://user:pass@localhost/kallithea?charset=utf8 +#sqlalchemy.url = mysql://user:pass@localhost/kallithea?charset=utf8 # see sqlalchemy docs for others -sqlalchemy.db1.echo = false -sqlalchemy.db1.pool_recycle = 3600 +sqlalchemy.echo = false +sqlalchemy.pool_recycle = 3600 ################################ ### ALEMBIC CONFIGURATION ####
--- a/kallithea/websetup.py Mon Sep 12 17:41:20 2016 +0200 +++ b/kallithea/websetup.py Mon Aug 22 17:50:51 2016 +0200 @@ -37,7 +37,7 @@ def setup_app(command, conf, vars): """Place any commands to setup kallithea here""" - dbconf = conf['sqlalchemy.db1.url'] + dbconf = conf['sqlalchemy.url'] dbmanage = DbManage(log_sql=True, dbconf=dbconf, root=conf['here'], tests=False, cli_args=command.options.__dict__) dbmanage.create_tables(override=True)
--- a/scripts/dbmigrate-test Mon Sep 12 17:41:20 2016 +0200 +++ b/scripts/dbmigrate-test Mon Aug 22 17:50:51 2016 +0200 @@ -65,7 +65,7 @@ cat <<EOD Config file: $config_file EOD -sed -n -e 's/^sqlalchemy\.db1\.url *= */Database URL: /p' "$config_file" +sed -n -e 's/^sqlalchemy\.url *= */Database URL: /p' "$config_file" cat <<EOD Working dir: $temp Repository: $source_repo
--- a/scripts/generate-ini.py Mon Sep 12 17:41:20 2016 +0200 +++ b/scripts/generate-ini.py Mon Aug 22 17:50:51 2016 +0200 @@ -60,7 +60,7 @@ 'archive_cache_dir': '%(here)s/../../data/test/tarballcache', 'beaker.cache.data_dir': '%(here)s/../../data/test/cache/data', 'beaker.cache.lock_dir': '%(here)s/../../data/test/cache/lock', - 'sqlalchemy.db1.url': 'sqlite:///%(here)s/kallithea_test.sqlite', + 'sqlalchemy.url': 'sqlite:///%(here)s/kallithea_test.sqlite', }, '[handler_console]': { 'level': 'DEBUG',