Mercurial > kallithea
changeset 4219:24498ba2fbec kallithea-2.2.5-rebrand
SETTINGS_PREFIX for identifiers (e.g., db table names) incl. project's name.
kallithea.SETTINGS_PREFIX is a variable string used as a prefix for specific
external identifiers, such as database table names (and likely later form
fields), so that the name of the project need not necessarily be encoded into
data.
This setting is configurable so that compatibility with old, similar
databases can be maintained at the users' request.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Fri, 23 May 2014 17:36:09 -0400 |
parents | f373f182b756 |
children | 56dadd0e5cf7 |
files | kallithea/__init__.py kallithea/lib/dbmigrate/schema/db_1_2_0.py kallithea/lib/dbmigrate/schema/db_1_3_0.py kallithea/lib/dbmigrate/schema/db_1_4_0.py kallithea/lib/dbmigrate/schema/db_1_5_0.py kallithea/lib/dbmigrate/schema/db_1_5_2.py kallithea/lib/dbmigrate/schema/db_1_6_0.py kallithea/lib/dbmigrate/schema/db_1_7_0.py kallithea/lib/dbmigrate/schema/db_1_8_0.py kallithea/lib/dbmigrate/schema/db_2_0_0.py kallithea/lib/dbmigrate/schema/db_2_0_1.py kallithea/lib/dbmigrate/schema/db_2_0_2.py kallithea/lib/dbmigrate/schema/db_2_1_0.py kallithea/lib/dbmigrate/schema/db_2_2_0.py kallithea/lib/dbmigrate/schema/db_2_2_3.py kallithea/lib/dbmigrate/versions/001_initial_release.py kallithea/model/db.py |
diffstat | 17 files changed, 78 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/__init__.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/__init__.py Fri May 23 17:36:09 2014 -0400 @@ -22,7 +22,7 @@ Original author and date, and relevant copyright and licensing information is below: :created_on: Apr 9, 2010 :author: marcink -:copyright: (c) 2013 RhodeCode GmbH, and others. +:copyright: (c) 2013 RhodeCode GmbH, (C) 2014 Bradley M. Kuhn, and others. :license: GPLv3, see LICENSE.md for more details. """ @@ -44,6 +44,20 @@ # Linked module for extensions EXTENSIONS = {} +# SETTINGS_PREFIX is the prefix to use for form fields and database table names. + +# Ideally, SETTINGS_PREFIX would be in an ini file of some sort instead of +# in this code. However, since this is used in kallithea/model/db.py as +# part of the database initialization in code that typically runs before +# CONFIG (above) is populated with settings from the ini file, it's instead +# hard-coded herein. + +SETTINGS_PREFIX = "kallithea_" +# NOTE: If you want compatibility with a database that was originally created +# for use with the Rhodecode software product, changing SETTINGS_PREFIX to +# "rhodecode_" might work to make the old database and forms compatible with +# this application. + try: from kallithea.lib import get_current_revision _rev = get_current_revision(quiet=True)
--- a/kallithea/lib/dbmigrate/schema/db_1_2_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_2_0.py Fri May 23 17:36:09 2014 -0400 @@ -49,6 +49,7 @@ from kallithea.model.meta import Base, Session from kallithea.lib.caching_query import FromCache +from kallithea import SETTINGS_PREFIX log = logging.getLogger(__name__) @@ -142,7 +143,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = (UniqueConstraint('app_settings_name'), {'extend_existing':True}) app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) app_settings_name = Column("app_settings_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) @@ -213,7 +214,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = (UniqueConstraint('ui_key'), {'extend_existing':True}) HOOK_UPDATE = 'changegroup.update'
--- a/kallithea/lib/dbmigrate/schema/db_1_3_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_3_0.py Fri May 23 17:36:09 2014 -0400 @@ -51,6 +51,7 @@ from kallithea.model.meta import Base, Session import hashlib +from kallithea import SETTINGS_PREFIX log = logging.getLogger(__name__) @@ -157,7 +158,7 @@ return '<DB:%s>' % (self.__class__.__name__) class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine':'InnoDB', @@ -232,7 +233,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine':'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_1_4_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_4_0.py Fri May 23 17:36:09 2014 -0400 @@ -55,6 +55,8 @@ from kallithea.model.meta import Base, Session +from kallithea import SETTINGS_PREFIX + URL_SEP = '/' log = logging.getLogger(__name__) @@ -148,7 +150,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -230,7 +232,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_1_5_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_5_0.py Fri May 23 17:36:09 2014 -0400 @@ -54,6 +54,8 @@ from kallithea.model.meta import Base, Session +from kallithea import SETTINGS_PREFIX + URL_SEP = '/' log = logging.getLogger(__name__) @@ -147,7 +149,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -246,7 +248,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_1_5_2.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_5_2.py Fri May 23 17:36:09 2014 -0400 @@ -58,6 +58,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -148,7 +150,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -247,7 +249,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_1_6_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_6_0.py Fri May 23 17:36:09 2014 -0400 @@ -58,6 +58,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -148,7 +150,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -247,7 +249,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_1_7_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_7_0.py Fri May 23 17:36:09 2014 -0400 @@ -58,6 +58,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -153,7 +155,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -252,7 +254,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_1_8_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_1_8_0.py Fri May 23 17:36:09 2014 -0400 @@ -58,6 +58,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -153,7 +155,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -270,7 +272,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_2_0_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_2_0_0.py Fri May 23 17:36:09 2014 -0400 @@ -59,6 +59,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -161,7 +163,7 @@ 'bool': str2bool, 'list': functools.partial(aslist, sep=',') } - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -317,7 +319,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_2_0_1.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_2_0_1.py Fri May 23 17:36:09 2014 -0400 @@ -56,6 +56,8 @@ from kallithea.model.meta import Base, Session +from kallithea import SETTINGS_PREFIX + URL_SEP = '/' log = logging.getLogger(__name__) @@ -164,7 +166,7 @@ 'bool': str2bool, 'list': functools.partial(aslist, sep=',') } - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -320,7 +322,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_2_0_2.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_2_0_2.py Fri May 23 17:36:09 2014 -0400 @@ -59,6 +59,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -164,7 +166,7 @@ 'bool': str2bool, 'list': functools.partial(aslist, sep=',') } - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -320,7 +322,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_2_1_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_2_1_0.py Fri May 23 17:36:09 2014 -0400 @@ -59,6 +59,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -157,7 +159,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -323,7 +325,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_2_2_0.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_2_2_0.py Fri May 23 17:36:09 2014 -0400 @@ -60,6 +60,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -158,7 +160,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -324,7 +326,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/schema/db_2_2_3.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/schema/db_2_2_3.py Fri May 23 17:36:09 2014 -0400 @@ -60,6 +60,8 @@ URL_SEP = '/' log = logging.getLogger(__name__) +from kallithea import SETTINGS_PREFIX + #============================================================================== # BASE CLASSES #============================================================================== @@ -158,7 +160,7 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -324,7 +326,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',
--- a/kallithea/lib/dbmigrate/versions/001_initial_release.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/lib/dbmigrate/versions/001_initial_release.py Fri May 23 17:36:09 2014 -0400 @@ -12,10 +12,12 @@ from kallithea.lib.dbmigrate.migrate import * +from kallithea import SETTINGS_PREFIX + log = logging.getLogger(__name__) class Setting(Base): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' __table_args__ = (UniqueConstraint('app_settings_name'), {'useexisting':True}) app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) app_settings_name = Column("app_settings_name", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) @@ -30,7 +32,7 @@ self.app_settings_value) class Ui(Base): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = {'useexisting':True} ui_id = Column("ui_id", Integer(), nullable=False, unique=True, default=None, primary_key=True) ui_section = Column("ui_section", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
--- a/kallithea/model/db.py Wed Jul 02 19:08:36 2014 -0400 +++ b/kallithea/model/db.py Fri May 23 17:36:09 2014 -0400 @@ -57,6 +57,8 @@ from kallithea.model.meta import Base, Session +from kallithea import SETTINGS_PREFIX + URL_SEP = '/' log = logging.getLogger(__name__) @@ -158,7 +160,8 @@ class Setting(Base, BaseModel): - __tablename__ = 'rhodecode_settings' + __tablename__ = SETTINGS_PREFIX + 'settings' + __table_args__ = ( UniqueConstraint('app_settings_name'), {'extend_existing': True, 'mysql_engine': 'InnoDB', @@ -324,7 +327,7 @@ class Ui(Base, BaseModel): - __tablename__ = 'rhodecode_ui' + __tablename__ = SETTINGS_PREFIX + 'ui' __table_args__ = ( UniqueConstraint('ui_key'), {'extend_existing': True, 'mysql_engine': 'InnoDB',