Changeset - bb735ce0ccbb
[Not reviewed]
Bradley M. Kuhn - 11 years ago 2014-07-03 01:05:31
bkuhn@sfconservancy.org
Rename set_rhodecode_config to set_app_settings
3 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/config/environment.py
Show inline comments
 
@@ -24,25 +24,25 @@ from mako.lookup import TemplateLookup
 
from pylons.configuration import PylonsConfig
 
from pylons.error import handle_mako_error
 

	
 
# don't remove this import it does magic for celery
 
from kallithea.lib import celerypylons
 

	
 
import kallithea.lib.app_globals as app_globals
 

	
 
from kallithea.config.routing import make_map
 

	
 
from kallithea.lib import helpers
 
from kallithea.lib.auth import set_available_permissions
 
from kallithea.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config,\
 
from kallithea.lib.utils import repo2db_mapper, make_ui, set_app_settings,\
 
    load_rcextensions, check_git_version, set_vcs_config
 
from kallithea.lib.utils2 import engine_from_config, str2bool
 
from kallithea.lib.db_manage import DbManage
 
from kallithea.model import init_model
 
from kallithea.model.scm import ScmModel
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
def load_environment(global_conf, app_conf, initial=False,
 
                     test_env=None, test_index=None):
 
    """
 
@@ -108,25 +108,25 @@ def load_environment(global_conf, app_co
 
        if test_index:
 
            create_test_index(TESTS_TMP_PATH, config, True)
 

	
 
    DbManage.check_waitress()
 
    # MULTIPLE DB configs
 
    # Setup the SQLAlchemy database engine
 
    sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
 
    init_model(sa_engine_db1)
 

	
 
    set_available_permissions(config)
 
    repos_path = make_ui('db').configitems('paths')[0][1]
 
    config['base_path'] = repos_path
 
    set_rhodecode_config(config)
 
    set_app_settings(config)
 

	
 
    instance_id = kallithea.CONFIG.get('instance_id')
 
    if instance_id == '*':
 
        instance_id = '%s-%s' % (platform.uname()[1], os.getpid())
 
        kallithea.CONFIG['instance_id'] = instance_id
 

	
 
    # CONFIGURATION OPTIONS HERE (note: all config options will override
 
    # any Pylons config options)
 

	
 
    # store config reference into our module to skip import magic of
 
    # pylons
 
    kallithea.CONFIG.update(config)
kallithea/controllers/admin/settings.py
Show inline comments
 
@@ -29,25 +29,25 @@ import traceback
 
import formencode
 

	
 
from formencode import htmlfill
 
from pylons import request, tmpl_context as c, url, config
 
from pylons.controllers.util import redirect
 
from pylons.i18n.translation import _
 

	
 
from kallithea.lib import helpers as h
 
from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator
 
from kallithea.lib.base import BaseController, render
 
from kallithea.lib.celerylib import tasks, run_task
 
from kallithea.lib.exceptions import HgsubversionImportError
 
from kallithea.lib.utils import repo2db_mapper, set_rhodecode_config
 
from kallithea.lib.utils import repo2db_mapper, set_app_settings
 
from kallithea.model.db import RhodeCodeUi, Repository, RhodeCodeSetting
 
from kallithea.model.forms import ApplicationSettingsForm, \
 
    ApplicationUiSettingsForm, ApplicationVisualisationForm
 
from kallithea.model.scm import ScmModel
 
from kallithea.model.notification import EmailNotificationModel
 
from kallithea.model.meta import Session
 
from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str
 
from kallithea.lib.compat import json
 
log = logging.getLogger(__name__)
 

	
 

	
 
class SettingsController(BaseController):
 
@@ -255,25 +255,25 @@ class SettingsController(BaseController)
 
                                            form_result['rhodecode_ga_code'])
 
                Session().add(sett3)
 

	
 
                sett4 = RhodeCodeSetting.create_or_update('captcha_public_key',
 
                                    form_result['rhodecode_captcha_public_key'])
 
                Session().add(sett4)
 

	
 
                sett5 = RhodeCodeSetting.create_or_update('captcha_private_key',
 
                                    form_result['rhodecode_captcha_private_key'])
 
                Session().add(sett5)
 

	
 
                Session().commit()
 
                set_rhodecode_config(config)
 
                set_app_settings(config)
 
                h.flash(_('Updated application settings'), category='success')
 

	
 
            except Exception:
 
                log.error(traceback.format_exc())
 
                h.flash(_('Error occurred during updating '
 
                          'application settings'),
 
                          category='error')
 

	
 
            return redirect(url('admin_settings_global'))
 

	
 
        defaults = RhodeCodeSetting.get_app_settings()
 
        defaults.update(self._get_hg_ui_settings())
 
@@ -312,25 +312,25 @@ class SettingsController(BaseController)
 
                    ('admin_grid_items', 'rhodecode_admin_grid_items', 'int'),
 
                    ('show_version', 'rhodecode_show_version', 'bool'),
 
                    ('use_gravatar', 'rhodecode_use_gravatar', 'bool'),
 
                    ('gravatar_url', 'rhodecode_gravatar_url', 'unicode'),
 
                    ('clone_uri_tmpl', 'rhodecode_clone_uri_tmpl', 'unicode'),
 
                ]
 
                for setting, form_key, type_ in settings:
 
                    sett = RhodeCodeSetting.create_or_update(setting,
 
                                        form_result[form_key], type_)
 
                    Session().add(sett)
 

	
 
                Session().commit()
 
                set_rhodecode_config(config)
 
                set_app_settings(config)
 
                h.flash(_('Updated visualisation settings'),
 
                        category='success')
 

	
 
            except Exception:
 
                log.error(traceback.format_exc())
 
                h.flash(_('Error occurred during updating '
 
                          'visualisation settings'),
 
                        category='error')
 

	
 
            return redirect(url('admin_settings_visual'))
 

	
 
        defaults = RhodeCodeSetting.get_app_settings()
kallithea/lib/utils.py
Show inline comments
 
@@ -385,25 +385,25 @@ def make_ui(read_from='file', path=None,
 
                baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key),
 
                                 safe_str(ui_.ui_value))
 
            if ui_.ui_key == 'push_ssl':
 
                # force set push_ssl requirement to False, rhodecode
 
                # handles that
 
                baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key),
 
                                 False)
 
        if clear_session:
 
            meta.Session.remove()
 
    return baseui
 

	
 

	
 
def set_rhodecode_config(config):
 
def set_app_settings(config):
 
    """
 
    Updates pylons config with new settings from database
 

	
 
    :param config:
 
    """
 
    hgsettings = RhodeCodeSetting.get_app_settings()
 

	
 
    for k, v in hgsettings.items():
 
        config[k] = v
 

	
 

	
 
def set_vcs_config(config):
0 comments (0 inline, 0 general)