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


Python Activity.create方法代码示例

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


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

示例1: add_follower

# 需要导入模块: from activity import Activity [as 别名]
# 或者: from activity.Activity import create [as 别名]
    def add_follower(cls, leader, follower):
        # TODO: expand to handle more than 5000 followers, using extra entities
        follower_id = follower.key().id()  # TickUser.get_by_user_id(follower.user_id(),keys_only=True).id()
        leader_id = leader.key().id()
        check = cls.all(keys_only=True).ancestor(leader).filter("followers_ids =", follower_id).get()
        if not check:
            entity = cls.all().ancestor(leader).filter("leader_id =", leader_id).get()
            if entity:
                entity.follower_ids.append(follower_id)
                index = entity.get_follow_index()
                index.add_followers(follower.all_user_ids)
                index.put()
                entity.put()
            else:
                new_entity = cls(parent=leader, leader_id=leader_id, follower_ids=[follower_id])
                new_entity.put()
                new_index = FollowIndex(parent=new_entity)
                new_index.add_leaders(leader.all_user_ids)
                new_index.add_followers(follower.all_user_ids)
                new_index.put()
            from activity import Activity

            Activity.create(
                "<actor>|began following|<target>", actor=follower, target=leader, extra_recipients=[leader]
            )
            return True
        else:
            return False
开发者ID:cheesun,项目名称:chees-test,代码行数:30,代码来源:follow.py

示例2: remove_follower

# 需要导入模块: from activity import Activity [as 别名]
# 或者: from activity.Activity import create [as 别名]
    def remove_follower(leader, follower):
        follower_id = follower.key().id()
        existing = (
            Follow.all()
            .ancestor(leader)
            .filter("leader_id =", leader.key().id())
            .filter("follower_ids =", follower_id)
            .get()
        )
        if not existing:
            return False
        existing.follower_ids.remove(follower_id)
        existing.put()
        # do dependent index
        index = existing.get_follow_index()
        for user_id in follower.all_user_ids:
            index.remove_follower(user_id)
        index.put()
        from activity import Activity

        Activity.create("<actor>|stopped following|<target>", actor=follower, target=leader, extra_recipients=[leader])
        return True
开发者ID:cheesun,项目名称:chees-test,代码行数:24,代码来源:follow.py


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