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


Python EventUser.save方法代码示例

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


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

示例1: _get_event_user

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import save [as 别名]
    def _get_event_user(self, project, data):
        user_data = data.get('sentry.interfaces.User')
        if not user_data:
            return

        euser = EventUser(
            project=project,
            ident=user_data.get('id'),
            email=user_data.get('email'),
            username=user_data.get('username'),
            ip_address=user_data.get('ip_address'),
        )

        if not euser.tag_value:
            return

        cache_key = 'euser:{}:{}'.format(
            project.id,
            md5_text(euser.tag_value).hexdigest(),
        )
        cached = default_cache.get(cache_key)
        if cached is None:
            try:
                with transaction.atomic(using=router.db_for_write(EventUser)):
                    euser.save()
            except IntegrityError:
                pass
            default_cache.set(cache_key, '', 3600)

        return euser
开发者ID:mvaled,项目名称:sentry,代码行数:32,代码来源:event_manager.py

示例2: record_affected_user

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import save [as 别名]
def record_affected_user(event, **kwargs):
    from sentry.models import EventUser, Group

    user_data = event.data.get('sentry.interfaces.User', event.data.get('user'))
    if not user_data:
        logger.info('No user data found for event_id=%s', event.event_id)
        return

    euser = EventUser(
        project=event.project,
        ident=user_data.get('id'),
        email=user_data.get('email'),
        username=user_data.get('username'),
        ip_address=user_data.get('ip_address'),
    )

    if not euser.tag_value:
        # no ident, bail
        logger.info('No identifying value found for user on event_id=%s',
                    event.event_id)
        return

    try:
        with transaction.atomic():
            euser.save()
    except IntegrityError:
        pass

    Group.objects.add_tags(event.group, [
        ('sentry:user', euser.tag_value)
    ])
开发者ID:haojiang1,项目名称:sentry,代码行数:33,代码来源:post_process.py

示例3: _get_event_user

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import save [as 别名]
    def _get_event_user(self, project, data):
        user_data = data.get("sentry.interfaces.User")
        if not user_data:
            return

        euser = EventUser(
            project=project,
            ident=user_data.get("id"),
            email=user_data.get("email"),
            username=user_data.get("username"),
            ip_address=user_data.get("ip_address"),
        )

        if not euser.tag_value:
            return

        cache_key = "euser:{}:{}".format(project.id, md5(euser.tag_value.encode("utf-8")).hexdigest())
        cached = default_cache.get(cache_key)
        if cached is None:
            try:
                with transaction.atomic(using=router.db_for_write(EventUser)):
                    euser.save()
            except IntegrityError:
                pass
            default_cache.set(cache_key, "", 3600)

        return euser
开发者ID:yoachum,项目名称:sentry,代码行数:29,代码来源:event_manager.py

示例4: _get_event_user

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import save [as 别名]
    def _get_event_user(self, project, data):
        user_data = data.get('sentry.interfaces.User')
        if not user_data:
            return

        euser = EventUser(
            project_id=project.id,
            ident=user_data.get('id'),
            email=user_data.get('email'),
            username=user_data.get('username'),
            ip_address=user_data.get('ip_address'),
            name=user_data.get('name'),
        )
        euser.set_hash()
        if not euser.hash:
            return

        cache_key = 'euserid:1:{}:{}'.format(
            project.id,
            euser.hash,
        )
        euser_id = default_cache.get(cache_key)
        if euser_id is None:
            try:
                with transaction.atomic(using=router.db_for_write(EventUser)):
                    euser.save()
            except IntegrityError:
                try:
                    euser = EventUser.objects.get(
                        project_id=project.id,
                        hash=euser.hash,
                    )
                except EventUser.DoesNotExist:
                    # why???
                    e_userid = -1
                else:
                    if euser.name != (user_data.get('name') or euser.name):
                        euser.update(
                            name=user_data['name'],
                        )
                    e_userid = euser.id
                default_cache.set(cache_key, e_userid, 3600)
        return euser
开发者ID:alshopov,项目名称:sentry,代码行数:45,代码来源:event_manager.py

示例5: _get_event_user

# 需要导入模块: from sentry.models import EventUser [as 别名]
# 或者: from sentry.models.EventUser import save [as 别名]
    def _get_event_user(self, project, data):
        user_data = data.get('sentry.interfaces.User')
        if not user_data:
            return

        euser = EventUser(
            project=project,
            ident=user_data.get('id'),
            email=user_data.get('email'),
            username=user_data.get('username'),
            ip_address=user_data.get('ip_address'),
        )

        if not euser.tag_value:
            return

        try:
            with transaction.atomic():
                euser.save()
        except IntegrityError:
            pass

        return euser
开发者ID:delkyd,项目名称:sentry,代码行数:25,代码来源:event_manager.py


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