当前位置: 首页>>代码示例>>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;未经允许,请勿转载。