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


Python Activity.query方法代码示例

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


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

示例1: queryActivities

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import query [as 别名]
    def queryActivities(self, request):
        """Query for activities."""
        activities = Activity.query()
        if request.fil:
            activities = Activity.query(Activity.tribe==request.fil)
        # need to fetch organiser displayName from profiles
        # get all keys and use get_multi for speed
        organisers = [(ndb.Key(Profile, acti.organizerUID)) for acti in activities]
        profiles = ndb.get_multi(organisers)

        # put display names in a dict for easier fetching
        names = {}
        for profile in profiles:
            names[profile.key.id()] = profile.displayName

        # return individual ActivityForm object per Activity
        return ActivityForms(
                items=[self._copyActivityToForm(acti, names[acti.organizerUID]) for acti in \
                activities]
        )
开发者ID:jerrayl,项目名称:DHTribes-source,代码行数:22,代码来源:activity.py

示例2: getActivitiesCreated

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import query [as 别名]
    def getActivitiesCreated(self, request):
        """Return activities created by user."""
        # make sure user is authed
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        # create ancestor query for all key matches for this user
        actis = Activity.query(ancestor=ndb.Key(Profile, user_id))
        prof = ndb.Key(Profile, user_id).get()
        # return set of ActivityForm objects per Activity
        return ActivityForms(
            items=[self._copyActivityToForm(acti, getattr(prof, 'displayName')) for acti in actis]
        )
开发者ID:jerrayl,项目名称:DHTribes-source,代码行数:17,代码来源:activity.py


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