本文整理匯總了Python中rhodecode.model.db.RhodeCodeSetting.get_by_name方法的典型用法代碼示例。如果您正苦於以下問題:Python RhodeCodeSetting.get_by_name方法的具體用法?Python RhodeCodeSetting.get_by_name怎麽用?Python RhodeCodeSetting.get_by_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rhodecode.model.db.RhodeCodeSetting
的用法示例。
在下文中一共展示了RhodeCodeSetting.get_by_name方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_ldap_options
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_by_name [as 別名]
def create_ldap_options(self, skip_existing=False):
"""Creates ldap settings"""
for k, v in [
("ldap_active", "false"),
("ldap_host", ""),
("ldap_port", "389"),
("ldap_tls_kind", "PLAIN"),
("ldap_tls_reqcert", ""),
("ldap_dn_user", ""),
("ldap_dn_pass", ""),
("ldap_base_dn", ""),
("ldap_filter", ""),
("ldap_search_scope", ""),
("ldap_attr_login", ""),
("ldap_attr_firstname", ""),
("ldap_attr_lastname", ""),
("ldap_attr_email", ""),
]:
if skip_existing and RhodeCodeSetting.get_by_name(k) != None:
log.debug("Skipping option %s" % k)
continue
setting = RhodeCodeSetting(k, v)
self.sa.add(setting)
示例2: create_default_options
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_by_name [as 別名]
def create_default_options(self, skip_existing=False):
"""Creates default settings"""
for k, v in [
('default_repo_enable_locking', False),
('default_repo_enable_downloads', False),
('default_repo_enable_statistics', False),
('default_repo_private', False),
('default_repo_type', 'hg')]:
if skip_existing and RhodeCodeSetting.get_by_name(k) != None:
log.debug('Skipping option %s' % k)
continue
setting = RhodeCodeSetting(k, v)
self.sa.add(setting)
示例3: create_ldap_options
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_by_name [as 別名]
def create_ldap_options(self, skip_existing=False):
"""Creates ldap settings"""
for k, v in [('ldap_active', 'false'), ('ldap_host', ''),
('ldap_port', '389'), ('ldap_tls_kind', 'PLAIN'),
('ldap_tls_reqcert', ''), ('ldap_dn_user', ''),
('ldap_dn_pass', ''), ('ldap_base_dn', ''),
('ldap_filter', ''), ('ldap_search_scope', ''),
('ldap_attr_login', ''), ('ldap_attr_firstname', ''),
('ldap_attr_lastname', ''), ('ldap_attr_email', '')]:
if skip_existing and RhodeCodeSetting.get_by_name(k) != None:
log.debug('Skipping option %s' % k)
continue
setting = RhodeCodeSetting(k, v)
self.sa.add(setting)
示例4: ldap_settings
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_by_name [as 別名]
def ldap_settings(self):
"""POST ldap create and store ldap settings"""
_form = LdapSettingsForm([x[0] for x in self.tls_reqcert_choices],
[x[0] for x in self.search_scope_choices],
[x[0] for x in self.tls_kind_choices])()
# check the ldap lib
ldap_active = False
try:
import ldap
ldap_active = True
except ImportError:
pass
try:
form_result = _form.to_python(dict(request.POST))
try:
for k, v in form_result.items():
if k.startswith('ldap_'):
if k == 'ldap_active':
v = v if ldap_active else False
setting = RhodeCodeSetting.get_by_name(k)
setting.app_settings_value = v
Session().add(setting)
Session().commit()
h.flash(_('LDAP settings updated successfully'),
category='success')
if not ldap_active:
#if ldap is missing send an info to user
h.flash(_('Unable to activate ldap. The "python-ldap" '
'library is missing.'), category='warning')
except (DatabaseError,):
raise
except formencode.Invalid, errors:
e = errors.error_dict or {}
return htmlfill.render(
render('admin/ldap/ldap.html'),
defaults=errors.value,
errors=e,
prefix_error=False,
encoding="UTF-8")
示例5: update
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_by_name [as 別名]
def update(self, setting_id):
"""PUT /admin/settings/setting_id: Update an existing item"""
# Forms posted to this method should contain a hidden field:
# <input type="hidden" name="_method" value="PUT" />
# Or using helpers:
# h.form(url('admin_setting', setting_id=ID),
# method='put')
# url('admin_setting', setting_id=ID)
if setting_id == 'mapping':
rm_obsolete = request.POST.get('destroy', False)
log.debug('Rescanning directories with destroy=%s' % rm_obsolete)
initial = ScmModel().repo_scan()
log.debug('invalidating all repositories')
for repo_name in initial.keys():
invalidate_cache('get_repo_cached_%s' % repo_name)
added, removed = repo2db_mapper(initial, rm_obsolete)
h.flash(_('Repositories successfully'
' rescanned added: %s,removed: %s') % (added, removed),
category='success')
if setting_id == 'whoosh':
repo_location = self.get_hg_ui_settings()['paths_root_path']
full_index = request.POST.get('full_index', False)
run_task(tasks.whoosh_index, repo_location, full_index)
h.flash(_('Whoosh reindex task scheduled'), category='success')
if setting_id == 'global':
application_form = ApplicationSettingsForm()()
try:
form_result = application_form.to_python(dict(request.POST))
try:
hgsettings1 = RhodeCodeSetting.get_by_name('title')
hgsettings1.app_settings_value = \
form_result['rhodecode_title']
hgsettings2 = RhodeCodeSetting.get_by_name('realm')
hgsettings2.app_settings_value = \
form_result['rhodecode_realm']
hgsettings3 = RhodeCodeSetting.get_by_name('ga_code')
hgsettings3.app_settings_value = \
form_result['rhodecode_ga_code']
self.sa.add(hgsettings1)
self.sa.add(hgsettings2)
self.sa.add(hgsettings3)
self.sa.commit()
set_rhodecode_config(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')
self.sa.rollback()
except formencode.Invalid, errors:
return htmlfill.render(
render('admin/settings/settings.html'),
defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
encoding="UTF-8")