Changeset - 24498ba2fbec
[Not reviewed]
Bradley M. Kuhn - 11 years ago 2014-05-23 23:36:09
bkuhn@sfconservancy.org
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.
17 files changed with 78 insertions and 33 deletions:
0 comments (0 inline, 0 general)
kallithea/__init__.py
Show inline comments
 
@@ -22,7 +22,7 @@ This file was forked by the Kallithea pr
 
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 @@ CONFIG = {}
 
# 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)
kallithea/lib/dbmigrate/schema/db_1_2_0.py
Show inline comments
 
@@ -49,6 +49,7 @@ from kallithea.lib.compat import json
 
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 BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (UniqueConstraint('ui_key'), {'extend_existing':True})
 

	
 
    HOOK_UPDATE = 'changegroup.update'
kallithea/lib/dbmigrate/schema/db_1_3_0.py
Show inline comments
 
@@ -51,6 +51,7 @@ from kallithea.lib.caching_query import 
 
from kallithea.model.meta import Base, Session
 
import hashlib
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -157,7 +158,7 @@ class BaseModel(object):
 
        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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine':'InnoDB',
kallithea/lib/dbmigrate/schema/db_1_4_0.py
Show inline comments
 
@@ -55,6 +55,8 @@ from kallithea.lib.caching_query import 
 

	
 
from kallithea.model.meta import Base, Session
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
@@ -148,7 +150,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_1_5_0.py
Show inline comments
 
@@ -54,6 +54,8 @@ from kallithea.lib.caching_query import 
 

	
 
from kallithea.model.meta import Base, Session
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
@@ -147,7 +149,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_1_5_2.py
Show inline comments
 
@@ -58,6 +58,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -148,7 +150,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_1_6_0.py
Show inline comments
 
@@ -58,6 +58,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -148,7 +150,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_1_7_0.py
Show inline comments
 
@@ -58,6 +58,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -153,7 +155,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_1_8_0.py
Show inline comments
 
@@ -58,6 +58,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -153,7 +155,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_2_0_0.py
Show inline comments
 
@@ -59,6 +59,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -161,7 +163,7 @@ class Setting(Base, BaseModel):
 
        '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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_2_0_1.py
Show inline comments
 
@@ -56,6 +56,8 @@ from kallithea.lib.caching_query import 
 

	
 
from kallithea.model.meta import Base, Session
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
@@ -164,7 +166,7 @@ class Setting(Base, BaseModel):
 
        '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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_2_0_2.py
Show inline comments
 
@@ -59,6 +59,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -164,7 +166,7 @@ class Setting(Base, BaseModel):
 
        '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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_2_1_0.py
Show inline comments
 
@@ -59,6 +59,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -157,7 +159,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_2_2_0.py
Show inline comments
 
@@ -60,6 +60,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -158,7 +160,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/schema/db_2_2_3.py
Show inline comments
 
@@ -60,6 +60,8 @@ from kallithea.model.meta import Base, S
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
#==============================================================================
 
# BASE CLASSES
 
#==============================================================================
 
@@ -158,7 +160,7 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
kallithea/lib/dbmigrate/versions/001_initial_release.py
Show inline comments
 
@@ -12,10 +12,12 @@ from kallithea.model.meta import Base
 

	
 
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 @@ class Setting(Base):
 
                                                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)
kallithea/model/db.py
Show inline comments
 
@@ -57,6 +57,8 @@ from kallithea.lib.caching_query import 
 

	
 
from kallithea.model.meta import Base, Session
 

	
 
from kallithea import SETTINGS_PREFIX
 

	
 
URL_SEP = '/'
 
log = logging.getLogger(__name__)
 

	
 
@@ -158,7 +160,8 @@ class BaseModel(object):
 

	
 

	
 
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 Setting(Base, BaseModel):
 

	
 

	
 
class Ui(Base, BaseModel):
 
    __tablename__ = 'rhodecode_ui'
 
    __tablename__ = SETTINGS_PREFIX + 'ui'
 
    __table_args__ = (
 
        UniqueConstraint('ui_key'),
 
        {'extend_existing': True, 'mysql_engine': 'InnoDB',
0 comments (0 inline, 0 general)