本文整理匯總了Python中rhodecode.model.db.RhodeCodeSetting.get_app_settings方法的典型用法代碼示例。如果您正苦於以下問題:Python RhodeCodeSetting.get_app_settings方法的具體用法?Python RhodeCodeSetting.get_app_settings怎麽用?Python RhodeCodeSetting.get_app_settings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rhodecode.model.db.RhodeCodeSetting
的用法示例。
在下文中一共展示了RhodeCodeSetting.get_app_settings方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __before__
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_app_settings [as 別名]
def __before__(self):
c.rhodecode_version = __version__
c.rhodecode_instanceid = config.get('instance_id')
c.rhodecode_name = config.get('rhodecode_title')
c.use_gravatar = str2bool(config.get('use_gravatar'))
c.ga_code = config.get('rhodecode_ga_code')
# Visual options
c.visual = AttributeDict({})
rc_config = RhodeCodeSetting.get_app_settings()
c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
c.visual.lightweight_dashboard = str2bool(rc_config.get('rhodecode_lightweight_dashboard'))
c.visual.lightweight_dashboard_items = safe_int(config.get('dashboard_items', 100))
c.repo_name = get_repo_slug(request)
c.backends = BACKENDS.keys()
c.unread_notifications = NotificationModel()\
.get_unread_cnt_for_user(c.rhodecode_user.user_id)
self.cut_off_limit = int(config.get('cut_off_limit'))
self.sa = meta.Session
self.scm_model = ScmModel(self.sa)
self.ip_addr = ''
示例2: __before__
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_app_settings [as 別名]
def __before__(self):
"""
__before__ is called before controller methods and after __call__
"""
c.rhodecode_version = __version__
c.rhodecode_instanceid = config.get('instance_id')
c.rhodecode_name = config.get('rhodecode_title')
c.use_gravatar = str2bool(config.get('use_gravatar'))
c.ga_code = config.get('rhodecode_ga_code')
# Visual options
c.visual = AttributeDict({})
rc_config = RhodeCodeSetting.get_app_settings()
## DB stored
c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
c.visual.dashboard_items = safe_int(rc_config.get('rhodecode_dashboard_items', 100))
c.visual.repository_fields = str2bool(rc_config.get('rhodecode_repository_fields'))
c.visual.show_version = str2bool(rc_config.get('rhodecode_show_version'))
## INI stored
self.cut_off_limit = int(config.get('cut_off_limit'))
c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))
c.repo_name = get_repo_slug(request) # can be empty
c.backends = BACKENDS.keys()
c.unread_notifications = NotificationModel()\
.get_unread_cnt_for_user(c.rhodecode_user.user_id)
self.sa = meta.Session
self.scm_model = ScmModel(self.sa)
示例3: set_rhodecode_config
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_app_settings [as 別名]
def set_rhodecode_config(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
示例4: index
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_app_settings [as 別名]
def index(self, format='html'):
"""GET /admin/settings: All items in the collection"""
# url('admin_settings')
defaults = RhodeCodeSetting.get_app_settings()
defaults.update(self.get_hg_ui_settings())
return htmlfill.render(
render('admin/settings/settings.html'),
defaults=defaults,
encoding="UTF-8",
force_defaults=False
)
示例5: authenticate
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_app_settings [as 別名]
def authenticate(username, password):
"""
Authentication function used for access control,
firstly checks for db authentication then if ldap is enabled for ldap
authentication, also creates ldap user if not in database
:param username: username
:param password: password
"""
user_model = UserModel()
user = User.get_by_username(username)
log.debug('Authenticating user using RhodeCode account')
if user is not None and not user.ldap_dn:
if user.active:
if user.username == 'default' and user.active:
log.info('user %s authenticated correctly as anonymous user' %
username)
return True
elif user.username == username and check_password(password,
user.password):
log.info('user %s authenticated correctly' % username)
return True
else:
user_obj = User.get_by_username(username, case_insensitive=True)
rc_config = RhodeCodeSetting.get_app_settings()
if user_obj is not None and str2bool(rc_config.get('rhodecode_imap_fallback')):
log.info('falling back to imap login')
imap_host = rc_config.get('rhodecode_imap_login_hostname')
imap_email = username + rc_config.get('rhodecode_imap_append_hostname')
log.info('trying imap login for %s against host %s' % (imap_email, imap_host))
imap_login_test = imaplib.IMAP4_SSL(imap_host)
try:
imap_login_test.login(imap_email, password)
log.info('imap login succeeded')
imap_login_test.logout()
return True
except(Exception,):
log.info('imap login failed')
imap_login_test.logout()
else:
log.info('not falling back to imap - fallback disabled')
else:
log.warning('user %s tried auth but is disabled' % username)
else:
log.debug('Regular authentication failed')
user_obj = User.get_by_username(username, case_insensitive=True)
if user_obj is not None and not user_obj.ldap_dn:
log.debug('this user already exists as non ldap')
return False
ldap_settings = RhodeCodeSetting.get_ldap_settings()
#======================================================================
# FALLBACK TO LDAP AUTH IF ENABLE
#======================================================================
if str2bool(ldap_settings.get('ldap_active')):
log.debug("Authenticating user using ldap")
kwargs = {
'server': ldap_settings.get('ldap_host', ''),
'base_dn': ldap_settings.get('ldap_base_dn', ''),
'port': ldap_settings.get('ldap_port'),
'bind_dn': ldap_settings.get('ldap_dn_user'),
'bind_pass': ldap_settings.get('ldap_dn_pass'),
'tls_kind': ldap_settings.get('ldap_tls_kind'),
'tls_reqcert': ldap_settings.get('ldap_tls_reqcert'),
'ldap_filter': ldap_settings.get('ldap_filter'),
'search_scope': ldap_settings.get('ldap_search_scope'),
'attr_login': ldap_settings.get('ldap_attr_login'),
'ldap_version': 3,
}
log.debug('Checking for ldap authentication')
try:
aldap = AuthLdap(**kwargs)
(user_dn, ldap_attrs) = aldap.authenticate_ldap(username,
password)
log.debug('Got ldap DN response %s' % user_dn)
get_ldap_attr = lambda k: ldap_attrs.get(ldap_settings\
.get(k), [''])[0]
user_attrs = {
'name': safe_unicode(get_ldap_attr('ldap_attr_firstname')),
'lastname': safe_unicode(get_ldap_attr('ldap_attr_lastname')),
'email': get_ldap_attr('ldap_attr_email'),
'active': 'hg.register.auto_activate' in User\
.get_by_username('default').AuthUser.permissions['global']
}
# don't store LDAP password since we don't need it. Override
# with some random generated password
#.........這裏部分代碼省略.........