當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。