##// END OF EJS Templates
Added tag v1.1.8 for changeset c8974135732a
Added tag v1.1.8 for changeset c8974135732a

File last commit:

r1217:a3b2b4b4 default
r1253:f8bd57cc default
Show More
settings.py
103 lines | 3.0 KiB | text/x-python | PythonLexer
rhodecode release 1.1.3 changes
r1057 # -*- coding: utf-8 -*-
"""
rhodecode.model.settings
~~~~~~~~~~~~~~~~~~~~~~~~
Settings model for RhodeCode
:created on Nov 17, 2010
:author: marcink
:copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
:license: GPLv3, see COPYING for more details.
"""
fixes for issue #149
r1217 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
Added settings model, and Exceptions lib....
r704 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
fixes for issue #149
r1217 #
Added settings model, and Exceptions lib....
r704 # You should have received a copy of the GNU General Public License
fixes for issue #149
r1217 # along with this program. If not, see <http://www.gnu.org/licenses/>.
fixed Example celery config to ampq,...
r752
rhodecode release 1.1.3 changes
r1057 import logging
fixed Example celery config to ampq,...
r752 from rhodecode.model import BaseModel
Added settings model, and Exceptions lib....
r704 from rhodecode.model.caching_query import FromCache
from rhodecode.model.db import RhodeCodeSettings
log = logging.getLogger(__name__)
fixed Example celery config to ampq,...
r752 class SettingsModel(BaseModel):
Added settings model, and Exceptions lib....
r704 """
Settings model
"""
def get(self, settings_key, cache=False):
r = self.sa.query(RhodeCodeSettings)\
.filter(RhodeCodeSettings.app_settings_name == settings_key).scalar()
if cache:
r = r.options(FromCache("sql_cache_short",
"get_setting_%s" % settings_key))
return r
rhodecode release 1.1.3 changes
r1057 def get_app_settings(self, cache=False):
"""Get's config from database, each config key is prefixed with
'rhodecode_' prefix, than global pylons config is updated with such
keys
"""
ret = self.sa.query(RhodeCodeSettings)
if cache:
ret = ret.options(FromCache("sql_cache_short", "get_hg_settings"))
project refactoring, cleaned up lib.utils from rarly used functions, and place them...
r756
if not ret:
raise Exception('Could not get application settings !')
settings = {}
for each in ret:
settings['rhodecode_' + each.app_settings_name] = each.app_settings_value
return settings
Added settings model, and Exceptions lib....
r704
def get_ldap_settings(self):
implements #60, ldap configuration and authentication....
r705 """
Returns ldap settings from database
:returns:
ldap_active
ldap_host
ldap_port
ldap_ldaps
rhodecode release 1.1.3 changes
r1057 ldap_tls_reqcert
implements #60, ldap configuration and authentication....
r705 ldap_dn_user
ldap_dn_pass
ldap_base_dn
rhodecode release 1.1.3 changes
r1057 ldap_filter
ldap_search_scope
ldap_attr_login
ldap_attr_firstname
ldap_attr_lastname
ldap_attr_email
implements #60, ldap configuration and authentication....
r705 """
rhodecode release 1.1.3 changes
r1057 # ldap_search_scope
Added settings model, and Exceptions lib....
r704
r = self.sa.query(RhodeCodeSettings)\
.filter(RhodeCodeSettings.app_settings_name\
.startswith('ldap_'))\
.all()
fd = {}
for row in r:
v = row.app_settings_value
fixed ldap settings
r1144 if v in ['true', 'yes', 'on', 'y', 't', '1']:
v = True
elif v in ['false', 'no', 'off', 'n', 'f', '0']:
v = False
Added settings model, and Exceptions lib....
r704 fd.update({row.app_settings_name:v})
return fd