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


Python User.get方法代码示例

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


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

示例1: main

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def main(request, username):
    """ API Endpoint for Device Synchronisation """

    if request.method == 'GET':
        return JsonResponse(get_sync_status(request.user))

    else:
        try:
            actions = json.loads(request.raw_post_data)
        except Exception as e:
            return HttpResponseBadRequest(str(e))

        synclist = actions.get('synchronize', [])
        stopsync = actions.get('stop-synchronize', [])

        try:
            update_sync_status(request.user, synclist, stopsync)
        except ValueError as e:
            return HttpResponseBadRequest(str(e))
        except DeviceDoesNotExist as e:
            return HttpResponseNotFound(str(e))

        # reload user to get current sync status
        user = User.get(request.user._id)
        return JsonResponse(get_sync_status(user))
开发者ID:Mic92,项目名称:mygpo,代码行数:27,代码来源:sync.py

示例2: _prepare_list

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
 def _prepare_list(self, l):
     podcasts = Podcast.get_multi(l.podcasts[:self.podcasts_per_topic])
     user = User.get(l.user)
     l = proxy_object(l)
     l.podcasts = podcasts
     l.username = user.username
     l.cls = "PodcastList"
     return l
开发者ID:Mic92,项目名称:mygpo,代码行数:10,代码来源:topics.py

示例3: import_file

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
    def import_file(self, user_id, filename):

        progress(0, 100, filename)

        with open(filename, 'r') as f:
            actions = json.load(f)

        progress(0, len(actions), filename)

        user = User.get(user_id)

        now = datetime.now()

        batch_size = 100

        count = len(actions) / batch_size

        for low in range(0, len(actions), batch_size):
            high = low+batch_size
            batch = actions[low:high]

            update_episodes(user, batch, now, None)

            progress(high, len(actions), filename)
开发者ID:fk-lx,项目名称:mygpo,代码行数:26,代码来源:import-episode-actions.py

示例4: _prepare_list

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
 def _prepare_list(l):
     user = User.get(l.user)
     l = proxy_object(l)
     l.username = user.username
     return l
开发者ID:Mic92,项目名称:mygpo,代码行数:7,代码来源:views.py

示例5: get_user_by_id

# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def get_user_by_id(user_id):
    from mygpo.users.models import User
    try:
        return User.get(user_id)
    except ResourceNotFound:
        return None
开发者ID:fk-lx,项目名称:mygpo,代码行数:8,代码来源:user.py


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