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


Python helpers.get_option函数代码示例

本文整理汇总了Python中sentry.plugins.helpers.get_option函数的典型用法代码示例。如果您正苦于以下问题:Python get_option函数的具体用法?Python get_option怎么用?Python get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: manage_project

def manage_project(request, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm('sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    # XXX: We probably shouldnt allow changing the team unless they're the project owner
    team_list = Team.objects.get_for_user(project.owner or request.user, MEMBER_OWNER)

    if request.user.has_perm('sentry.can_change_project'):
        form_cls = EditProjectAdminForm
    else:
        form_cls = EditProjectForm

    form = form_cls(request, team_list, request.POST or None, instance=project, initial={
        'origins': '\n'.join(get_option('sentry:origins', project) or []),
        'owner': project.owner,
    })

    if form.is_valid():
        project = form.save()
        set_option('sentry:origins', form.cleaned_data.get('origins') or [], project)
        return HttpResponseRedirect(request.path + '?success=1')

    context = csrf(request)
    context.update({
        'can_remove_project': can_remove_project(request.user, project),
        'page': 'details',
        'form': form,
        'project': project,
        'TEAM_LIST': team_list.values(),
        'SECTION': 'settings',
    })

    return render_to_response('sentry/projects/manage.html', context, request)
开发者ID:cheekybastard,项目名称:sentry,代码行数:34,代码来源:projects.py

示例2: test_get_option_with_project

    def test_get_option_with_project(self):
        with mock.patch('sentry.models.ProjectOption.objects.get_value') as get_value:
            project = mock.Mock()
            result = get_option('key', project)
            self.assertEquals(result, get_value.return_value)

            get_value.assert_called_once_with(project, 'key', None)
开发者ID:755,项目名称:sentry,代码行数:7,代码来源:tests.py

示例3: test_run_check_update_task_with_bad_response

    def test_run_check_update_task_with_bad_response(self):
        with mock.patch('sentry.tasks.check_update.fetch_url_content') as fetch:
            fetch.return_value = (None, None, '')
            check_update()  # latest_version == current_version
            fetch.assert_called_once_with(PYPI_URL)

        self.assertEqual(get_option(key=self.KEY), None)
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:7,代码来源:tests.py

示例4: test_run_check_update_task

    def test_run_check_update_task(self, safe_urlread, safe_urlopen):
        safe_urlread.return_value = json.dumps({'info': {'version': self.NEW}})

        check_update()  # latest_version > current_version

        safe_urlopen.assert_called_once_with(PYPI_URL)
        safe_urlread.assert_called_once_with(safe_urlopen.return_value)

        self.assertEqual(get_option(key=self.KEY), self.NEW)
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:9,代码来源:tests.py

示例5: test_run_check_update_task

    def test_run_check_update_task(self):
        with mock.patch('sentry.tasks.check_update.fetch_url_content') as fetch:
            fetch.return_value = (
                None, None, json.dumps({'info': {'version': self.NEW}})
            )
            check_update()  # latest_version > current_version
            fetch.assert_called_once_with(PYPI_URL)

        self.assertEqual(get_option(key=self.KEY), self.NEW)
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:9,代码来源:tests.py

示例6: test_run_check_update_task_with_bad_response

    def test_run_check_update_task_with_bad_response(self, safe_urlread,
                                                     safe_urlopen):
        safe_urlread.return_value = ''

        check_update()  # latest_version == current_version

        safe_urlopen.assert_called_once_with(PYPI_URL)
        safe_urlread.assert_called_once_with(safe_urlopen.return_value)

        self.assertEqual(get_option(key=self.KEY), None)
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:10,代码来源:tests.py

示例7: get_option

    def get_option(self, key, project=None, user=None):
        """
        Returns the value of an option in your plugins keyspace, or ``None`` if
        one is not present.

        If ``project`` is passed, it will limit the scope to that project's keyspace.

        >>> value = plugin.get_option('my_option')
        """
        from sentry.plugins.helpers import get_option
        return get_option(self._get_option_key(key), project, user)
开发者ID:alexandrul,项目名称:sentry,代码行数:11,代码来源:v1.py

示例8: get_origins

def get_origins(project=None):
    if settings.ALLOW_ORIGIN == '*':
        return '*'
    elif settings.ALLOW_ORIGIN:
        result = settings.ALLOW_ORIGIN.split(' ')
    else:
        result = []

    if project:
        optval = get_option('sentry:origins', project)
        if optval:
            result.extend(map(lambda x: x.lower(), optval))

    return frozenset(filter(bool, result))
开发者ID:canerdogan,项目名称:sentry,代码行数:14,代码来源:http.py

示例9: is_valid_origin

def is_valid_origin(origin, project=None):
    if settings.ALLOW_ORIGIN == '*':
        return True

    origin = origin.lower()
    if origin in (settings.ALLOW_ORIGIN or '').split(' '):
        return True

    if not project:
        return False

    optval = get_option('sentry:origins', project)
    if not optval:
        return False

    return origin not in itertools.imap(unicode.lower, unicode(optval))
开发者ID:SimpleTax,项目名称:sentry,代码行数:16,代码来源:http.py

示例10: get_origins

def get_origins(project=None):
    # TODO: we should cache this
    if settings.ALLOW_ORIGIN == '*':
        return frozenset(['*'])
    elif settings.ALLOW_ORIGIN:
        result = settings.ALLOW_ORIGIN.split(' ')
    else:
        result = []

    if project:
        optval = get_option('sentry:origins', project)
        if optval:
            result.extend(optval)

    # lowercase and strip the trailing slash from all origin values
    # filter out empty values
    return frozenset(filter(bool, map(lambda x: x.lower().rstrip('/'), result)))
开发者ID:DamianZaremba,项目名称:sentry,代码行数:17,代码来源:http.py

示例11: apply_access_control_headers

def apply_access_control_headers(response, project=None):
    """
    Provides the Access-Control headers to enable cross-site HTTP requests. You
    can find more information about these headers here:
    https://developer.mozilla.org/En/HTTP_access_control#Simple_requests
    """
    origin = settings.ALLOW_ORIGIN or ''
    if project and origin is not '*':
        optval = get_option('sentry:origins', project)
        if optval:
            origin = ('%s %s' % (origin, ' '.join(optval))).strip()

    if origin:
        response['Access-Control-Allow-Origin'] = origin
        response['Access-Control-Allow-Headers'] = 'X-Sentry-Auth, Authentication'
        response['Access-Control-Allow-Methods'] = 'POST'

    return response
开发者ID:Technigami,项目名称:sentry,代码行数:18,代码来源:http.py

示例12: manage_project

def manage_project(request, project):
    result = plugins.first("has_perm", request.user, "edit_project", project)
    if result is False and not request.user.has_perm("sentry.can_change_project"):
        return HttpResponseRedirect(reverse("sentry"))

    team_list = Team.objects.get_for_user(request.user, MEMBER_OWNER)

    if request.user.has_perm("sentry.can_change_project"):
        form_cls = EditProjectAdminForm
    else:
        form_cls = EditProjectForm

    form = form_cls(
        request,
        team_list,
        request.POST or None,
        instance=project,
        initial={"origins": "\n".join(get_option("sentry:origins", project) or []), "owner": project.owner},
    )

    if form.is_valid():
        project = form.save()
        set_option("sentry:origins", form.cleaned_data.get("origins") or [], project)
        return HttpResponseRedirect(request.path + "?success=1")

    if not project.team:
        member_list = []
    else:
        member_list = [(tm, tm.user) for tm in project.team.member_set.select_related("user")]

    context = csrf(request)
    context.update(
        {
            "can_remove_project": can_remove_project(request.user, project),
            "page": "details",
            "form": form,
            "project": project,
            "member_list": member_list,
            "TEAM_LIST": team_list.values(),
        }
    )

    return render_to_response("sentry/projects/manage.html", context, request)
开发者ID:nkabir,项目名称:sentry,代码行数:43,代码来源:projects.py

示例13: manage_project

def manage_project(request, team, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm('sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    # XXX: We probably shouldnt allow changing the team unless they're the project owner
    team_list = Team.objects.get_for_user(project.owner or request.user, MEMBER_OWNER)

    can_admin_project = request.user == project.owner or request.user.has_perm('sentry.can_change_project')

    if can_admin_project:
        form_cls = EditProjectAdminForm
    else:
        form_cls = EditProjectForm

    form = form_cls(request, team_list, request.POST or None, instance=project, initial={
        'origins': '\n'.join(get_option('sentry:origins', project) or []),
        'owner': project.owner,
    })

    if form.is_valid():
        project = form.save()
        set_option('sentry:origins', form.cleaned_data.get('origins') or [], project)

        messages.add_message(request, messages.SUCCESS,
            _('Changes to your project were saved.'))

        return HttpResponseRedirect(reverse('sentry-manage-project', args=[team.slug, project.slug]))

    context = csrf(request)
    context.update({
        'team': team,
        'can_remove_project': can_remove_project(request.user, project),
        'page': 'details',
        'form': form,
        'project': project,
        'SECTION': 'team',
        'SUBSECTION': 'projects'
    })

    return render_to_response('sentry/projects/manage.html', context, request)
开发者ID:TracyWebTech,项目名称:sentry,代码行数:41,代码来源:projects.py

示例14: manage_project

def manage_project(request, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm('sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    team_list = Team.objects.get_for_user(request.user, MEMBER_OWNER)

    if request.user.has_perm('sentry.can_change_project'):
        form_cls = EditProjectAdminForm
    else:
        form_cls = EditProjectForm

    form = form_cls(request, team_list, request.POST or None, instance=project, initial={
        'origins': '\n'.join(get_option('sentry:origins', project) or []),
        'owner': project.owner,
    })

    if form.is_valid():
        project = form.save()
        set_option('sentry:origins', form.cleaned_data.get('origins') or [], project)
        return HttpResponseRedirect(request.path + '?success=1')

    if not project.team:
        member_list = []
    else:
        member_list = [(tm, tm.user) for tm in project.team.member_set.select_related('user')]

    context = csrf(request)
    context.update({
        'can_remove_project': can_remove_project(request.user, project),
        'page': 'details',
        'form': form,
        'project': project,
        'member_list': member_list,
        'TEAM_LIST': team_list.values(),
    })

    return render_to_response('sentry/projects/manage.html', context, request)
开发者ID:Fashiolista,项目名称:sentry,代码行数:38,代码来源:projects.py

示例15: test_set_sentry_version_empty_latest

 def test_set_sentry_version_empty_latest(self):
     set_sentry_version(latest=self.NEW)
     self.assertEqual(get_option(key=self.KEY), self.NEW)
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:3,代码来源:tests.py


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