• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python serializers.serialize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

    def get(self, request, share_id):
        """
        Retrieve an aggregate

        Return details on an individual aggregate specified by it's shared ID.

            {method} {path}

        Note: This is not the equivilant of what you'd receive with the standard
        group details endpoint. Data is more restrictive and designed
        specifically for sharing.

        """
        try:
            group = Group.from_share_id(share_id)
        except Group.DoesNotExist:
            raise ResourceDoesNotExist

        if group.organization.flags.disable_shared_issues:
            raise ResourceDoesNotExist

        event = group.get_latest_event()

        context = serialize(group, request.user, SharedGroupSerializer())
        context['latestEvent'] = serialize(event, request.user, SharedEventSerializer())

        # TODO(dcramer): use specific serializer for public group and embed
        # event details as part of api response
        return Response(context)
开发者ID:IthacaDream,项目名称:sentry,代码行数:29,代码来源:shared_group_details.py


示例2: get_attrs

    def get_attrs(self, item_list, user):
        # TODO(dcramer); assert on relations
        users = {
            d['id']: d
            for d in serialize(set(i.user for i in item_list if i.user_id), user)
        }

        commit_ids = {
            i.data['commit']
            for i in item_list
            if i.type == Activity.SET_RESOLVED_IN_COMMIT
        }
        if commit_ids:
            commit_list = list(Commit.objects.filter(id__in=commit_ids))
            commits_by_id = {
                c.id: d
                for c, d in zip(commit_list, serialize(commit_list, user))
            }
            commits = {
                i: commits_by_id.get(i.data['commit'])
                for i in item_list
                if i.type == Activity.SET_RESOLVED_IN_COMMIT
            }
        else:
            commits = {}

        return {
            item: {
                'user': users[six.text_type(item.user_id)] if item.user_id else None,
                'commit': commits.get(item),
            } for item in item_list
        }
开发者ID:rlugojr,项目名称:sentry,代码行数:32,代码来源:activity.py


示例3: test_simple

    def test_simple(self):
        user = self.create_user(username='foo')
        organization = self.create_organization(owner=user)
        team = self.create_team(organization=organization)
        project = self.create_project(teams=[team], organization=organization, name='foo')
        project2 = self.create_project(teams=[team], organization=organization, name='bar')

        result = serialize(team, user, TeamWithProjectsSerializer())
        serialized_projects = serialize([project2, project], user)

        assert result == {
            'slug': team.slug,
            'name': team.name,
            'hasAccess': True,
            'isPending': False,
            'isMember': False,
            'id': six.text_type(team.id),
            'projects': serialized_projects,
            'avatar': {
                'avatarType': 'letter_avatar',
                'avatarUuid': None,
            },
            'memberCount': 0,
            'dateCreated': team.date_added,
        }
开发者ID:yaoqi,项目名称:sentry,代码行数:25,代码来源:test_team.py


示例4: get

    def get(self, request, organization_slug):
        organization = Organization.objects.get_from_cache(
            slug=organization_slug,
        )

        assert_perm(organization, request.user, request.auth)

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

        project_list = []
        for team in team_list:
            project_list.extend(Project.objects.get_for_user(
                team=team,
                user=request.user,
            ))
        project_list.sort(key=lambda x: x.name)

        team_map = dict(
            (t.id, c) for (t, c) in zip(team_list, serialize(team_list, request.user)),
        )

        context = []
        for project, pdata in zip(project_list, serialize(project_list, request.user)):
            pdata['team'] = team_map[project.team_id]
            context.append(pdata)

        return Response(context)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:30,代码来源:organization_projects.py


示例5: get

    def get(self, request, organization):
        """
        List an organization's projects

        Return a list of projects bound to a organization.

            {method} {path}

        """
        team_list = Team.objects.get_for_user(
            organization=organization,
            user=request.user,
        )

        project_list = []
        for team in team_list:
            project_list.extend(Project.objects.get_for_user(
                team=team,
                user=request.user,
            ))
        project_list.sort(key=lambda x: x.name)

        team_map = dict(
            (t.id, c) for (t, c) in zip(team_list, serialize(team_list, request.user)),
        )

        context = []
        for project, pdata in zip(project_list, serialize(project_list, request.user)):
            pdata['team'] = team_map[project.team_id]
            context.append(pdata)

        return Response(context)
开发者ID:ChadKillingsworth,项目名称:sentry,代码行数:32,代码来源:organization_projects.py


示例6: test_simple

    def test_simple(self):
        projects_ids = [self.project.id, self.project_2.id]
        org_members = list(self.org.member_set.filter(
            user__in=[
                self.owner_user,
                self.user_2,
            ],
        ).order_by('user__email'))
        result = serialize(
            org_members,
            self.user_2,
            OrganizationMemberWithProjectsSerializer(project_ids=projects_ids),
        )
        expected_projects = [
            [self.project.slug, self.project_2.slug],
            [self.project.slug]
        ]
        expected_projects[0].sort()
        assert [r['projects'] for r in result] == expected_projects

        projects_ids = [self.project_2.id]
        result = serialize(
            org_members,
            self.user_2,
            OrganizationMemberWithProjectsSerializer(project_ids=projects_ids),
        )
        expected_projects = [
            [self.project_2.slug],
            [],
        ]
        assert [r['projects'] for r in result] == expected_projects
开发者ID:yaoqi,项目名称:sentry,代码行数:31,代码来源:test_organization_member.py


示例7: get

    def get(self, request, wizard_hash=None):
        """
        This tries to retrieve and return the cache content if possible
        otherwise creates new cache
        """
        if wizard_hash is not None:
            key = '%s%s' % (SETUP_WIZARD_CACHE_KEY, wizard_hash)
            wizard_data = default_cache.get(key)

            if wizard_data is None:
                return Response(status=404)
            elif wizard_data == 'empty':
                # when we just created a clean cache
                return Response(status=400)

            return Response(serialize(wizard_data))
        else:
            # This creates a new available hash url for the project wizard
            rate_limited = ratelimits.is_limited(
                key='rl:setup-wizard:ip:%s' % request.META['REMOTE_ADDR'],
                limit=10,
            )
            if rate_limited:
                logger.info('setup-wizard.rate-limit')
                return Response(
                    {
                        'Too wizard requests',
                    }, status=403
                )
            wizard_hash = get_random_string(
                64, allowed_chars='abcdefghijklmnopqrstuvwxyz012345679')

            key = '%s%s' % (SETUP_WIZARD_CACHE_KEY, wizard_hash)
            default_cache.set(key, 'empty', SETUP_WIZARD_CACHE_TIMEOUT)
            return Response(serialize({'hash': wizard_hash}))
开发者ID:Kayle009,项目名称:sentry,代码行数:35,代码来源:setup_wizard.py


示例8: react_plugin_config

def react_plugin_config(plugin, project, request):
    response = client.get(
        '/projects/{}/{}/plugins/{}/'.format(
            project.organization.slug,
            project.slug,
            plugin.slug,
        ),
        request=request
    )

    return mark_safe(
        """
    <div id="ref-plugin-config"></div>
    <script>
    $(function(){
        ReactDOM.render(React.createFactory(Sentry.PluginConfig)({
            project: %s,
            organization: %s,
            data: %s
        }), document.getElementById('ref-plugin-config'));
    });
    </script>
    """ % (
            json.dumps_htmlsafe(serialize(project, request.user)),
            json.dumps_htmlsafe(serialize(project.organization, request.user)),
            json.dumps_htmlsafe(response.data)
        )
    )
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:28,代码来源:configuration.py


示例9: test_environment

    def test_environment(self):
        group = self.group

        environment = Environment.get_or_create(group.project, 'production')

        from sentry.api.serializers.models.group import tsdb

        with mock.patch(
                'sentry.api.serializers.models.group.tsdb.get_range',
                side_effect=tsdb.get_range) as get_range:
            serialize(
                [group],
                serializer=StreamGroupSerializer(
                    environment_func=lambda: environment,
                    stats_period='14d',
                ),
            )
            assert get_range.call_count == 1
            for args, kwargs in get_range.call_args_list:
                assert kwargs['environment_id'] == environment.id

        def get_invalid_environment():
            raise Environment.DoesNotExist()

        with mock.patch(
                'sentry.api.serializers.models.group.tsdb.make_series',
                side_effect=tsdb.make_series) as make_series:
            serialize(
                [group],
                serializer=StreamGroupSerializer(
                    environment_func=get_invalid_environment,
                    stats_period='14d',
                )
            )
            assert make_series.call_count == 1
开发者ID:hosmelq,项目名称:sentry,代码行数:35,代码来源:test_group.py


示例10: get

    def get(self, request, organization):
        """
        Retrieve an organization

        Return details on an individual organization including various details
        such as membership access, features, and teams.

            {method} {path}

        """
        team_list = list(Team.objects.filter(
            organization=organization,
            status=TeamStatus.VISIBLE,
        ))

        feature_list = []
        if features.has('organizations:sso', organization, actor=request.user):
            feature_list.append('sso')

        if getattr(organization.flags, 'allow_joinleave'):
            feature_list.append('open-membership')

        context = serialize(organization, request.user)
        context['access'] = access.from_user(request.user, organization).scopes
        context['features'] = feature_list
        context['teams'] = serialize(
            team_list, request.user, TeamWithProjectsSerializer())
        return Response(context)
开发者ID:nagyistoce,项目名称:sentry,代码行数:28,代码来源:organization_details.py


示例11: test_simple

    def test_simple(self):
        user = self.create_user(username='foo')
        organization = self.create_organization(owner=user)
        team = self.create_team(organization=organization)
        project = self.create_project(teams=[team], organization=organization, name='foo')
        project2 = self.create_project(teams=[team], organization=organization, name='bar')

        result = serialize(team, user, TeamWithProjectsSerializer())
        result.pop('dateCreated')

        # don't compare dateCreated because of mysql
        serialized_projects = serialize([project2, project], user)
        for p in serialized_projects:
            p.pop('dateCreated')

        for p in result['projects']:
            p.pop('dateCreated')

        assert result == {
            'slug': team.slug,
            'name': team.name,
            'hasAccess': True,
            'isPending': False,
            'isMember': False,
            'id': six.text_type(team.id),
            'projects': serialized_projects,
            'avatar': {
                'avatarType': 'letter_avatar',
                'avatarUuid': None,
            },
        }
开发者ID:binlee1990,项目名称:sentry,代码行数:31,代码来源:test_team.py


示例12: test_environment

    def test_environment(self):
        group = self.group

        environment = Environment.get_or_create(group.project, 'production')

        with mock.patch(
                'sentry.api.serializers.models.group.snuba_tsdb.get_range',
                side_effect=snuba_tsdb.get_range) as get_range:
            serialize(
                [group],
                serializer=StreamGroupSerializerSnuba(
                    environment_ids=[environment.id],
                    stats_period='14d',
                ),
            )
            assert get_range.call_count == 1
            for args, kwargs in get_range.call_args_list:
                assert kwargs['environment_ids'] == [environment.id]

        with mock.patch(
                'sentry.api.serializers.models.group.snuba_tsdb.get_range',
                side_effect=snuba_tsdb.get_range) as get_range:
            serialize(
                [group],
                serializer=StreamGroupSerializerSnuba(
                    environment_ids=None,
                    stats_period='14d',
                )
            )
            assert get_range.call_count == 1
            for args, kwargs in get_range.call_args_list:
                assert kwargs['environment_ids'] is None
开发者ID:Kayle009,项目名称:sentry,代码行数:32,代码来源:test_group.py


示例13: get

    def get(self, request, project):
        """
        List a Project's DSym Files
        ```````````````````````````

        Retrieve a list of dsym files for a given project.

        :pparam string organization_slug: the slug of the organization the
                                          release belongs to.
        :pparam string project_slug: the slug of the project to list the
                                     dsym files of.
        :auth: required
        """

        apps = DSymApp.objects.filter(project=project)
        dsym_files = VersionDSymFile.objects.filter(
            dsym_app=apps
        ).select_related('dsym_file').order_by('-build', 'version')

        file_list = ProjectDSymFile.objects.filter(
            project=project,
            versiondsymfile__isnull=True,
        ).select_related('file')[:100]

        download_requested = request.GET.get('download_id') is not None
        if download_requested and (request.access.has_scope('project:write')):
            return self.download(request.GET.get('download_id'), project)

        return Response(
            {
                'apps': serialize(list(apps)),
                'debugSymbols': serialize(list(dsym_files)),
                'unreferencedDebugSymbols': serialize(list(file_list)),
            }
        )
开发者ID:binlee1990,项目名称:sentry,代码行数:35,代码来源:dsym_files.py


示例14: test_seen_stats

    def test_seen_stats(self):
        group = self.create_group(first_seen=self.week_ago, times_seen=5)

        # should use group columns when no environments arg passed
        result = serialize(group, serializer=GroupSerializerSnuba())
        assert result['count'] == '5'
        assert result['lastSeen'] == group.last_seen
        assert result['firstSeen'] == group.first_seen

        environment = self.create_environment(project=group.project)
        environment2 = self.create_environment(project=group.project)

        self.create_event(
            'a' * 32, group=group, datetime=self.day_ago, tags={'environment': environment.name}
        )
        self.create_event(
            'b' * 32, group=group, datetime=self.min_ago, tags={'environment': environment.name}
        )
        self.create_event(
            'c' * 32, group=group, datetime=self.min_ago, tags={'environment': environment2.name}
        )

        result = serialize(
            group, serializer=GroupSerializerSnuba(
                environment_ids=[environment.id, environment2.id])
        )
        assert result['count'] == '3'
        # result is rounded down to nearest second
        assert result['lastSeen'] == self.min_ago - timedelta(microseconds=self.min_ago.microsecond)
        assert result['firstSeen'] == self.day_ago - \
            timedelta(microseconds=self.day_ago.microsecond)
开发者ID:Kayle009,项目名称:sentry,代码行数:31,代码来源:test_group.py


示例15: get_payload_v0

def get_payload_v0(event):
    from sentry.api.serializers import serialize

    group = event.group
    project = group.project

    project_url_base = absolute_uri(u'/{}/{}'.format(
        project.organization.slug,
        project.slug,
    ))

    group_context = serialize(group)
    group_context['url'] = u'{}/issues/{}/'.format(
        project_url_base,
        group.id,
    )

    event_context = serialize(event)
    event_context['url'] = u'{}/issues/{}/events/{}/'.format(
        project_url_base,
        group.id,
        event.id,
    )
    data = {
        'project': {
            'slug': project.slug,
            'name': project.name,
        },
        'group': group_context,
        'event': event_context,
    }
    return data
开发者ID:alexandrul,项目名称:sentry,代码行数:32,代码来源:servicehooks.py


示例16: get

    def get(self, request, group, environment):
        # XXX(dcramer): we have no great way to pass the empty env
        if environment == 'none':
            environment = ''

        first_release = GroupRelease.objects.filter(
            group_id=group.id,
            environment=environment,
        ).order_by('first_seen').first()

        last_release = GroupRelease.objects.filter(
            group_id=group.id,
            environment=environment,
        ).order_by('-first_seen').first()

        stats_args = self._parse_args(request)

        context = {
            'environment': {
                'name': environment,
            },
            'firstRelease': serialize(first_release, request.user),
            'lastRelease': serialize(
                last_release, request.user, GroupReleaseWithStatsSerializer(
                    since=stats_args['start'],
                    until=stats_args['end'],
                )
            ),
        }
        return Response(context)
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:sentry,代码行数:30,代码来源:group_environment_details.py


示例17: get

    def get(self, request, project):
        """
        List a project's processing issues.
        """
        num_issues = ProcessingIssue.objects.filter(
            project=project
        ).count()

        last_seen = ProcessingIssue.objects.filter(
            project=project
        ).order_by('-datetime').first()

        resolveable_issues, has_more = ProcessingIssue.objects \
            .find_resolved(project_id=project.id)

        reprocessing_issues = ReprocessingReport.objects \
            .filter(project_id=project.id).count()

        data = {
            'hasIssues': num_issues > 0,
            'numIssues': num_issues,
            'lastSeen': last_seen and serialize(last_seen.datetime) or None,
            'resolveableIssues': len(resolveable_issues),
            'hasMoreResolveableIssues': has_more,
            'issuesProcessing': reprocessing_issues,
        }

        if request.GET.get('detailed') == '1':
            q = ProcessingIssue.objects.with_num_events().filter(
                project=project
            ).order_by('type')
            data['issues'] = [serialize(x, request.user) for x in q]

        return Response(serialize(data, request.user))
开发者ID:rlugojr,项目名称:sentry,代码行数:34,代码来源:project_processingissues.py


示例18: get

    def get(self, request, group_id):
        """
        Retrieve an aggregate

        Return details on an individual aggregate.

            {method} {path}

        """
        group = Group.objects.get(
            id=group_id,
        )

        assert_perm(group, request.user, request.auth)

        data = serialize(group, request.user)

        # TODO: these probably should be another endpoint
        activity = self._get_activity(request, group, num=7)
        seen_by = self._get_seen_by(request, group)

        data.update({
            'activity': serialize(activity, request.user),
            'seenBy': serialize(seen_by, request.user),
        })

        return Response(data)
开发者ID:brettlangdon,项目名称:sentry,代码行数:27,代码来源:group_details.py


示例19: get

    def get(self, request, project):
        """
        Retrieve a Project
        ``````````````````

        Return details on an individual project.

        :pparam string organization_slug: the slug of the organization the
                                          project belongs to.
        :pparam string project_slug: the slug of the project to delete.
        :auth: required
        """
        active_plugins = [
            {
                'name': plugin.get_title(),
                'id': plugin.slug,
            }
            for plugin in plugins.configurable_for_project(project, version=None)
            if plugin.is_enabled(project)
            and plugin.has_project_conf()
        ]

        data = serialize(project, request.user)
        data['options'] = {
            'sentry:origins': '\n'.join(project.get_option('sentry:origins', ['*']) or []),
            'sentry:resolve_age': int(project.get_option('sentry:resolve_age', 0)),
            'sentry:scrub_data': bool(project.get_option('sentry:scrub_data', True)),
            'sentry:sensitive_fields': project.get_option('sentry:sensitive_fields', []),
        }
        data['activePlugins'] = active_plugins
        data['team'] = serialize(project.team, request.user)
        data['organization'] = serialize(project.organization, request.user)

        return Response(data)
开发者ID:noah-lee,项目名称:sentry,代码行数:34,代码来源:project_details.py


示例20: test_simple

    def test_simple(self):
        user = self.create_user()
        project = self.create_project()
        release = Release.objects.create(
            project=project,
            version=uuid4().hex,
            new_groups=1,
        )
        TagValue.objects.create(
            project=release.project,
            key='sentry:release',
            value=release.version,
            first_seen=timezone.now(),
            last_seen=timezone.now(),
            times_seen=5,
        )

        result = serialize(release, user)
        assert result['version'] == release.version
        assert result['shortVersion'] == release.version
        assert result['newGroups'] == 1
        assert result['firstEvent']
        assert result['lastEvent']

        # Make sure a sha1 value gets truncated
        release.version = '0' * 40
        result = serialize(release, user)
        assert result['shortVersion'] == '0' * 12
开发者ID:280185386,项目名称:sentry,代码行数:28,代码来源:test_release.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python buffer.incr函数代码示例发布时间:2022-05-27
下一篇:
Python permissions.assert_perm函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap