當前位置: 首頁>>代碼示例>>Python>>正文


Python NodeLog.load方法代碼示例

本文整理匯總了Python中website.models.NodeLog.load方法的典型用法代碼示例。如果您正苦於以下問題:Python NodeLog.load方法的具體用法?Python NodeLog.load怎麽用?Python NodeLog.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在website.models.NodeLog的用法示例。


在下文中一共展示了NodeLog.load方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_log

# 需要導入模塊: from website.models import NodeLog [as 別名]
# 或者: from website.models.NodeLog import load [as 別名]
    def get_log(self):
        log = NodeLog.load(self.kwargs.get('log_id'))
        if not log:
            raise NotFound(
                detail='No log matching that log_id could be found.'
            )

        self.check_object_permissions(self.request, log)
        return log
開發者ID:545zhou,項目名稱:osf.io,代碼行數:11,代碼來源:views.py

示例2: get_registered_from

# 需要導入模塊: from website.models import NodeLog [as 別名]
# 或者: from website.models.NodeLog import load [as 別名]
def get_registered_from(registration):
    """
    Gets node registration was registered from.  Handles deleted registrations where registered_from is null.

    """
    if registration.registered_from:
        return registration.registered_from_id
    else:
        first_log_id = db['node'].find_one({'_id': registration._id})['logs'][0]
        log = NodeLog.load(first_log_id)
        return log.params.get('node') or log.params.get('project')
開發者ID:545zhou,項目名稱:osf.io,代碼行數:13,代碼來源:migrate_registration_logs.py

示例3: get_queryset

# 需要導入模塊: from website.models import NodeLog [as 別名]
# 或者: from website.models.NodeLog import load [as 別名]
 def get_queryset(self):
     log = NodeLog.load(self.kwargs.get('log_id'))
     if not log:
         raise NotFound(
             detail='No log matching that log_id could be found.'
         )
     else:
         auth_user = get_user_auth(self.request)
         return [
             node for node in log.node__logged
             if node.can_view(auth_user)
         ]
開發者ID:mauromsl,項目名稱:osf.io,代碼行數:14,代碼來源:views.py

示例4: main

# 需要導入模塊: from website.models import NodeLog [as 別名]
# 或者: from website.models.NodeLog import load [as 別名]
def main():
    total = NodeLog.objects.all().count()
    count = 0
    page_size = 50000
    with transaction.atomic():
        qs = NodeLog.objects.all().order_by('-date').select_related('user').select_related('node').select_related('user___guid').select_related('node___guid')
        with server_side_cursors(qs, itersize=page_size):
            for log in qs.iterator():
                modm_nodelog = MODMNodeLog.load(log.guid)
                if modm_nodelog is not None:
                    modm_node = modm_nodelog.node
                    modm_user = modm_nodelog.user
                    if log.user is not None and log.user._guid.guid != modm_user._id:
                        print 'User doesn\'t match on log {}; {} != {}'.format(
                            log.guid, modm_user._id, log.user._guid.guid)
                    if log.node is not None and log.node._guid.guid != modm_nodelog.node._id:
                        print 'Node doesn\'t match on log {}; {} != {}'.format(
                            log.guid, modm_nodelog.node._id, log.node._guid.guid)
                    if log.date is not None and pytz.utc.localize(
                            modm_nodelog.date) != log.date:
                        print 'Date doesn\'t match on log {}'.format(log.guid)
                    if log.action is not None and log.action != modm_nodelog.action:
                        print 'Action doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.action, log.action)
                    if log.params is not None and log.params != modm_nodelog.params:
                        print 'Params doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.params, log.params)
                    if log.should_hide is not None and log.should_hide != modm_nodelog.should_hide:
                        print 'Should_hide does\'nt match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.should_hide, log.should_hide)
                    if log.foreign_user is not None and log.foreign_user != '' and log.foreign_user != modm_nodelog.foreign_user:
                        print 'Foreign_user doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.foreign_user, log.foreign_user)
                else:
                    print 'MODMNodeLog with id {} not found.'.format(log.guid)

                count += 1
                if count % page_size == 0:
                    MODMNodeLog._cache.clear()
                    MODMNodeLog._object_cache.clear()
                    print '{} through {}'.format(count, count + page_size)
開發者ID:wearpants,項目名稱:osf_models,代碼行數:43,代碼來源:verify_nodelogs.py


注:本文中的website.models.NodeLog.load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。