当前位置: 首页>>代码示例>>Python>>正文


Python Setting.get_app_settings方法代码示例

本文整理汇总了Python中kallithea.model.db.Setting.get_app_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.get_app_settings方法的具体用法?Python Setting.get_app_settings怎么用?Python Setting.get_app_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kallithea.model.db.Setting的用法示例。


在下文中一共展示了Setting.get_app_settings方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: password_reset

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def password_reset(self):
        settings = Setting.get_app_settings()
        captcha_private_key = settings.get('captcha_private_key')
        c.captcha_active = bool(captcha_private_key)
        c.captcha_public_key = settings.get('captcha_public_key')

        if request.POST:
            password_reset_form = PasswordResetForm()()
            try:
                form_result = password_reset_form.to_python(dict(request.POST))
                if c.captcha_active:
                    from kallithea.lib.recaptcha import submit
                    response = submit(request.POST.get('recaptcha_challenge_field'),
                                      request.POST.get('recaptcha_response_field'),
                                      private_key=captcha_private_key,
                                      remoteip=self.ip_addr)
                    if c.captcha_active and not response.is_valid:
                        _value = form_result
                        _msg = _('bad captcha')
                        error_dict = {'recaptcha_field': _msg}
                        raise formencode.Invalid(_msg, _value, None,
                                                 error_dict=error_dict)
                UserModel().reset_password_link(form_result)
                h.flash(_('Your password reset link was sent'),
                            category='success')
                return redirect(url('login_home'))

            except formencode.Invalid, errors:
                return htmlfill.render(
                    render('/password_reset.html'),
                    defaults=errors.value,
                    errors=errors.error_dict or {},
                    prefix_error=False,
                    encoding="UTF-8",
                    force_defaults=False)
开发者ID:msabramo,项目名称:kallithea,代码行数:37,代码来源:login.py

示例2: settings_system_update

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def settings_system_update(self):
        """GET /admin/settings/system/updates: All items in the collection"""
        # url('admin_settings_system_update')
        import json
        import urllib2
        from kallithea.lib.verlib import NormalizedVersion
        from kallithea import __version__

        defaults = Setting.get_app_settings()
        defaults.update(self._get_hg_ui_settings())
        _update_url = defaults.get('update_url', '')
        _update_url = "" # FIXME: disabled

        _err = lambda s: '<div style="color:#ff8888; padding:4px 0px">%s</div>' % (s)
        try:
            import kallithea
            ver = kallithea.__version__
            log.debug('Checking for upgrade on `%s` server' % _update_url)
            opener = urllib2.build_opener()
            opener.addheaders = [('User-agent', 'Kallithea-SCM/%s' % ver)]
            response = opener.open(_update_url)
            response_data = response.read()
            data = json.loads(response_data)
        except urllib2.URLError, e:
            log.error(traceback.format_exc())
            return _err('Failed to contact upgrade server: %r' % e)
开发者ID:msabramo,项目名称:kallithea,代码行数:28,代码来源:settings.py

示例3: settings_mapping

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def settings_mapping(self):
        """GET /admin/settings/mapping: All items in the collection"""
        # url('admin_settings_mapping')
        c.active = 'mapping'
        if request.POST:
            rm_obsolete = request.POST.get('destroy', False)
            install_git_hooks = request.POST.get('hooks', False)
            invalidate_cache = request.POST.get('invalidate', False)
            log.debug('rescanning repo location with destroy obsolete=%s and '
                      'install git hooks=%s' % (rm_obsolete,install_git_hooks))

            if invalidate_cache:
                log.debug('invalidating all repositories cache')
                for repo in Repository.get_all():
                    ScmModel().mark_for_invalidation(repo.repo_name, delete=True)

            filesystem_repos = ScmModel().repo_scan()
            added, removed = repo2db_mapper(filesystem_repos, rm_obsolete,
                                            install_git_hook=install_git_hooks,
                                            user=c.authuser.username)
            h.flash(h.literal(_('Repositories successfully rescanned. Added: %s. Removed: %s.') %
                (', '.join(h.link_to(safe_unicode(repo_name), h.url('summary_home', repo_name=repo_name))
                 for repo_name in added) or '-',
                 ', '.join(h.escape(safe_unicode(repo_name)) for repo_name in removed) or '-')),
                category='success')
            return redirect(url('admin_settings_mapping'))

        defaults = Setting.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)
开发者ID:msabramo,项目名称:kallithea,代码行数:37,代码来源:settings.py

示例4: settings_search

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def settings_search(self):
        c.active = 'search'
        if request.POST:
            repo_location = self._get_hg_ui_settings()['paths_root_path']
            full_index = request.POST.get('full_index', False)
            tasks.whoosh_index(repo_location, full_index)
            h.flash(_('Whoosh reindex task scheduled'), category='success')
            raise HTTPFound(location=url('admin_settings_search'))

        defaults = Setting.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)
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:19,代码来源:settings.py

示例5: settings_system

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def settings_system(self):
        c.active = 'system'

        defaults = Setting.get_app_settings()
        defaults.update(self._get_hg_ui_settings())

        import kallithea
        c.ini = kallithea.CONFIG
        c.update_url = defaults.get('update_url')
        server_info = Setting.get_server_info()
        for key, val in server_info.iteritems():
            setattr(c, key, val)

        return htmlfill.render(
            render('admin/settings/settings.html'),
            defaults=defaults,
            encoding="UTF-8",
            force_defaults=False)
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:20,代码来源:settings.py

示例6: settings_search

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def settings_search(self):
        """GET /admin/settings/search: All items in the collection"""
        # url('admin_settings_search')
        c.active = 'search'
        if request.POST:
            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')
            return redirect(url('admin_settings_search'))

        defaults = Setting.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)
开发者ID:msabramo,项目名称:kallithea,代码行数:21,代码来源:settings.py

示例7: test_captcha_deactivate

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def test_captcha_deactivate(self):
        self.log_user()
        old_title = 'Kallithea'
        old_realm = 'Kallithea authentication'
        new_ga_code = ''
        response = self.app.post(url('admin_settings_global'),
                        params=dict(title=old_title,
                                 realm=old_realm,
                                 ga_code=new_ga_code,
                                 captcha_private_key='',
                                 captcha_public_key='1234567890',
                                 _authentication_token=self.authentication_token(),
                                 ))

        self.checkSessionFlash(response, 'Updated application settings')
        assert Setting.get_app_settings()['captcha_private_key'] == ''

        response = self.app.get(url('register'))
        response.mustcontain(no=['captcha'])
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:21,代码来源:test_admin_settings.py

示例8: test_ga_code_inactive

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def test_ga_code_inactive(self):
        self.log_user()
        old_title = 'Kallithea'
        old_realm = 'Kallithea authentication'
        new_ga_code = ''
        response = self.app.post(url('admin_settings_global'),
                        params=dict(title=old_title,
                                 realm=old_realm,
                                 ga_code=new_ga_code,
                                 captcha_private_key='',
                                 captcha_public_key='',
                                 _authentication_token=self.authentication_token(),
                                 ))

        self.checkSessionFlash(response, 'Updated application settings')
        assert Setting.get_app_settings()['ga_code'] == new_ga_code

        response = response.follow()
        response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code])
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:21,代码来源:test_admin_settings.py

示例9: settings_mapping

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def settings_mapping(self):
        c.active = 'mapping'
        if request.POST:
            rm_obsolete = request.POST.get('destroy', False)
            install_git_hooks = request.POST.get('hooks', False)
            overwrite_git_hooks = request.POST.get('hooks_overwrite', False);
            invalidate_cache = request.POST.get('invalidate', False)
            log.debug('rescanning repo location with destroy obsolete=%s, '
                      'install git hooks=%s and '
                      'overwrite git hooks=%s' % (rm_obsolete, install_git_hooks, overwrite_git_hooks))

            filesystem_repos = ScmModel().repo_scan()
            added, removed = repo2db_mapper(filesystem_repos, rm_obsolete,
                                            install_git_hooks=install_git_hooks,
                                            user=request.authuser.username,
                                            overwrite_git_hooks=overwrite_git_hooks)
            h.flash(h.literal(_('Repositories successfully rescanned. Added: %s. Removed: %s.') %
                (', '.join(h.link_to(safe_unicode(repo_name), h.url('summary_home', repo_name=repo_name))
                 for repo_name in added) or '-',
                 ', '.join(h.escape(safe_unicode(repo_name)) for repo_name in removed) or '-')),
                category='success')

            if invalidate_cache:
                log.debug('invalidating all repositories cache')
                i = 0
                for repo in Repository.query():
                    try:
                        ScmModel().mark_for_invalidation(repo.repo_name)
                        i += 1
                    except VCSError as e:
                        log.warning('VCS error invalidating %s: %s', repo.repo_name, e)
                h.flash(_('Invalidated %s repositories') % i, category='success')

            raise HTTPFound(location=url('admin_settings_mapping'))

        defaults = Setting.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)
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:45,代码来源:settings.py

示例10: test_title_change

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
    def test_title_change(self):
        self.log_user()
        old_title = 'Kallithea'
        new_title = old_title + '_changed'
        old_realm = 'Kallithea authentication'

        for new_title in ['Changed', 'Żółwik', old_title]:
            response = self.app.post(url('admin_settings_global'),
                        params=dict(title=new_title,
                                 realm=old_realm,
                                 ga_code='',
                                 captcha_private_key='',
                                 captcha_public_key='',
                                 _authentication_token=self.authentication_token(),
                                ))

            self.checkSessionFlash(response, 'Updated application settings')
            assert Setting.get_app_settings()['title'] == new_title.decode('utf-8')

            response = response.follow()
            response.mustcontain("""<span class="branding">%s</span>""" % new_title)
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:23,代码来源:test_admin_settings.py

示例11: Session

# 需要导入模块: from kallithea.model.db import Setting [as 别名]
# 或者: from kallithea.model.db.Setting import get_app_settings [as 别名]
                                    form_result['captcha_private_key'])
                Session().add(sett5)

                Session().commit()
                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 = Setting.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)

    @HasPermissionAllDecorator('hg.admin')
    def settings_visual(self):
        """GET /admin/settings/visual: All items in the collection"""
        # url('admin_settings_visual')
        c.active = 'visual'
        if request.POST:
            application_form = ApplicationVisualisationForm()()
开发者ID:msabramo,项目名称:kallithea,代码行数:33,代码来源:settings.py


注:本文中的kallithea.model.db.Setting.get_app_settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。