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


Python Guid.load方法代码示例

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


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

示例1: _set_up_registration_with_comment

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def _set_up_registration_with_comment(self):
     self.registration = RegistrationFactory(creator=self.user, comment_level='private')
     self.registration_wiki = NodeWikiFactory(node=self.registration, user=self.user)
     self.registration_comment = CommentFactory(node=self.registration, target=Guid.load(self.registration_wiki._id), user=self.user)
     self.comment_url = '/{}comments/{}/'.format(API_BASE, self.registration_comment._id)
     reply_target = Guid.load(self.registration_comment._id)
     self.registration_comment_reply = CommentFactory(node=self.registration, target=reply_target, user=self.user)
开发者ID:baylee-d,项目名称:osf.io,代码行数:9,代码来源:test_comment_detail.py

示例2: test_migrate_project_comment_reply

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_migrate_project_comment_reply(self):
     comment = self._set_up_comment_with_target(root_target=self.project, target=self.project)
     reply = self._set_up_comment_with_target(root_target=self.project, target=comment)
     update_comment_targets_to_guids()
     reply.reload()
     assert_equal(reply.root_target, Guid.load(self.project._id))
     assert_equal(reply.target, Guid.load(comment._id))
开发者ID:545zhou,项目名称:osf.io,代码行数:9,代码来源:test_migrate_comment_targets.py

示例3: _set_up_public_project_with_comment

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def _set_up_public_project_with_comment(self):
     self.public_project = ProjectFactory.create(is_public=True, creator=self.user, comment_level='private')
     self.public_project.add_contributor(self.contributor, save=True)
     self.public_wiki = NodeWikiFactory(node=self.public_project, user=self.user)
     self.public_comment = CommentFactory(node=self.public_project, target=Guid.load(self.public_wiki._id), user=self.user)
     reply_target = Guid.load(self.public_comment._id)
     self.public_comment_reply = CommentFactory(node=self.public_project, target=reply_target, user=self.user)
     self.public_url = '/{}comments/{}/'.format(API_BASE, self.public_comment._id)
     self.public_comment_payload = self._set_up_payload(self.public_comment._id)
开发者ID:baylee-d,项目名称:osf.io,代码行数:11,代码来源:test_comment_detail.py

示例4: migrate_guids

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
def migrate_guids(guid_type, provider):
    cls = models.FileNode.resolve_class(provider, models.FileNode.FILE)

    for guid in paginated(guid_type):
        # Note: No metadata is populated here
        # It will be populated whenever this guid is next viewed
        if guid.node is None:
            logger.warning('{}({})\'s node is None; skipping'.format(guid_type, guid._id))
            continue

        if guid.waterbutler_path in ('/{{ revision.osfDownloadUrl }}', '/{{ currentVersion().osfDownloadUrl }}', '/{{ currentVersion().osfDownloadUrl }}', '/{{ node.urls.files }}', '/{{ revision.extra.user.url }}'):
            logger.warning('{}({})\'s is a googlebot path; skipping'.format(guid_type, guid._id))
            continue

        logger.debug('Migrating guid {} ({})'.format(guid._id, guid.waterbutler_path))

        try:
            file_node = cls(
                node=guid.node,
                path=guid.waterbutler_path,
                name=guid.waterbutler_path,
                materialized_path=guid.waterbutler_path,
            )
            file_node.save()
        except exceptions.KeyExistsException:
            file_node = cls.find_one(
                Q('node', 'eq', guid.node) &
                Q('path', 'eq', guid.waterbutler_path)
            )
            logger.warning('{!r}({}) has multiple guids'.format(file_node.wrapped(), guid._id))

        actual_guid = Guid.load(guid._id)
        actual_guid.referent = file_node
        actual_guid.save()
开发者ID:545zhou,项目名称:osf.io,代码行数:36,代码来源:migrate_file_guids.py

示例5: test_private_node_only_logged_in_contributor_commenter_can_delete_own_reply

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_private_node_only_logged_in_contributor_commenter_can_delete_own_reply(self):
     self._set_up_private_project_with_comment()
     reply_target = Guid.load(self.comment._id)
     reply = CommentFactory(node=self.private_project, target=reply_target, user=self.user)
     reply_url = '/{}comments/{}/'.format(API_BASE, reply)
     res = self.app.delete_json_api(reply_url, auth=self.user.auth)
     assert_equal(res.status_code, 204)        
开发者ID:baylee-d,项目名称:osf.io,代码行数:9,代码来源:test_comment_detail.py

示例6: get_paginated_response

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
    def get_paginated_response(self, data):
        """Add number of unread comments to links.meta when viewing list of comments filtered by
        a target node, file or wiki page."""
        response = super(CommentPagination, self).get_paginated_response(data)
        response_dict = response.data
        kwargs = self.request.parser_context['kwargs'].copy()

        if self.request.query_params.get('related_counts', False):
            target_id = self.request.query_params.get('filter[target]', None)
            node_id = kwargs.get('node_id', None)
            node = Node.load(node_id)
            user = self.request.user
            if target_id and not user.is_anonymous() and node.is_contributor(user):
                root_target = Guid.load(target_id)
                if root_target:
                    page = getattr(root_target.referent, 'root_target_page', None)
                    if page:
                        if not len(data):
                            unread = 0
                        else:
                            unread = Comment.find_n_unread(user=user, node=node, page=page, root_id=target_id)
                        if self.request.version < '2.1':
                            response_dict['links']['meta']['unread'] = unread
                        else:
                            response_dict['meta']['unread'] = unread
        return Response(response_dict)
开发者ID:alexschiller,项目名称:osf.io,代码行数:28,代码来源:pagination.py

示例7: update_file_guid_referent

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
def update_file_guid_referent(self, node, event_type, payload, user=None):
    if event_type == 'addon_file_moved' or event_type == 'addon_file_renamed':
        source = payload['source']
        destination = payload['destination']
        source_node = Node.load(source['node']['_id'])
        destination_node = node
        file_guids = FileNode.resolve_class(source['provider'], FileNode.ANY).get_file_guids(
            materialized_path=source['materialized'] if source['provider'] != 'osfstorage' else source['path'],
            provider=source['provider'],
            node=source_node)

        if event_type == 'addon_file_renamed' and source['provider'] in settings.ADDONS_BASED_ON_IDS:
            return
        if event_type == 'addon_file_moved' and (source['provider'] == destination['provider'] and
                                                 source['provider'] in settings.ADDONS_BASED_ON_IDS) and source_node == destination_node:
            return

        for guid in file_guids:
            obj = Guid.load(guid)
            if source_node != destination_node and Comment.find(Q('root_target', 'eq', guid)).count() != 0:
                update_comment_node(guid, source_node, destination_node)

            if source['provider'] != destination['provider'] or source['provider'] != 'osfstorage':
                old_file = FileNode.load(obj.referent._id)
                obj.referent = create_new_file(obj, source, destination, destination_node)
                obj.save()
                if old_file and not TrashedFileNode.load(old_file._id):
                    old_file.delete()
开发者ID:caspinelli,项目名称:osf.io,代码行数:30,代码来源:comment.py

示例8: test_public_node_non_contributor_commenter_can_delete_wiki_comment

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_public_node_non_contributor_commenter_can_delete_wiki_comment(self):
     project = ProjectFactory(is_public=True, comment_level='public')
     test_wiki = NodeWikiFactory(node=project, user=self.user)
     comment = CommentFactory(node=project, target=Guid.load(test_wiki), user=self.non_contributor)
     url = '/{}comments/{}/'.format(API_BASE, comment._id)
     res = self.app.delete_json_api(url, auth=self.non_contributor.auth)
     assert_equal(res.status_code, 204)
开发者ID:baylee-d,项目名称:osf.io,代码行数:9,代码来源:test_comment_detail.py

示例9: test_migrate_file_comment_reply

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_migrate_file_comment_reply(self):
     test_file = create_test_file(node=self.project, user=self.project.creator)
     comment = self._set_up_comment_with_target(root_target=test_file, target=test_file)
     reply = self._set_up_comment_with_target(root_target=test_file, target=comment)
     update_comment_targets_to_guids()
     reply.reload()
     assert_equal(reply.root_target, test_file.get_guid())
     assert_equal(reply.target, Guid.load(comment._id))
开发者ID:545zhou,项目名称:osf.io,代码行数:10,代码来源:test_migrate_comment_targets.py

示例10: test_find_unread_includes_comment_replies

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_find_unread_includes_comment_replies(self):
     project = ProjectFactory()
     user = UserFactory()
     project.add_contributor(user)
     project.save()
     comment = CommentFactory(node=project, user=user)
     reply = CommentFactory(node=project, target=Guid.load(comment._id), user=project.creator)
     n_unread = Comment.find_n_unread(user=user, node=project, page='node')
     assert_equal(n_unread, 1)
开发者ID:545zhou,项目名称:osf.io,代码行数:11,代码来源:test_comments.py

示例11: update_comment_targets_to_guids

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
def update_comment_targets_to_guids():
    comments = Comment.find()
    for comment in comments:
        # Skip comments on deleted files
        if not comment.target:
            continue
        if isinstance(comment.root_target, StoredFileNode):
            comment.root_target = comment.root_target.get_guid()
        elif comment.root_target:
            comment.root_target = Guid.load(comment.root_target._id)

        if isinstance(comment.target, StoredFileNode):
            comment.target = comment.target.get_guid()
        else:
            comment.target = Guid.load(comment.target._id)

        comment.save()
        logger.info("Migrated root_target and target for comment {0}".format(comment._id))
开发者ID:kch8qx,项目名称:osf.io,代码行数:20,代码来源:migrate_comment_targets.py

示例12: test_wiki_has_comments_link

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_wiki_has_comments_link(self):
     self._set_up_public_project_with_wiki_page()
     res = self.app.get(self.public_url)
     assert_equal(res.status_code, 200)
     url = res.json['data']['relationships']['comments']['links']['related']['href']
     CommentFactory(node=self.public_project, target=Guid.load(self.public_wiki._id), user=self.user)
     res = self.app.get(url)
     assert_equal(res.status_code, 200)
     assert_equal(res.json['data'][0]['type'], 'comments')
开发者ID:baylee-d,项目名称:osf.io,代码行数:11,代码来源:test_wiki_detail.py

示例13: get_target

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def get_target(self, node_id, target_id):
     target = Guid.load(target_id)
     if not target or not getattr(target.referent, 'belongs_to_node', None):
         raise ValueError('Invalid comment target.')
     elif not target.referent.belongs_to_node(node_id):
         raise ValueError('Cannot post to comment target on another node.')
     elif isinstance(target.referent, StoredFileNode) and target.referent.provider not in osf_settings.ADDONS_COMMENTABLE:
             raise ValueError('Comments are not supported for this file provider.')
     return target
开发者ID:fredtoh,项目名称:osf.io,代码行数:11,代码来源:serializers.py

示例14: get_redirect_url

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def get_redirect_url(self, **kwargs):
     guid = Guid.load(kwargs['guids'])
     if guid:
         referent = guid.referent
         if getattr(referent, 'absolute_api_v2_url', None):
             return referent.absolute_api_v2_url
         else:
             raise EndpointNotImplementedError()
     return None
开发者ID:mrphishxxx,项目名称:osf.io,代码行数:11,代码来源:views.py

示例15: test_public_node_non_contributor_commenter_can_update_wiki_comment

# 需要导入模块: from framework.guid.model import Guid [as 别名]
# 或者: from framework.guid.model.Guid import load [as 别名]
 def test_public_node_non_contributor_commenter_can_update_wiki_comment(self):
     project = ProjectFactory(is_public=True)
     test_wiki = NodeWikiFactory(node=project, user=self.user)
     comment = CommentFactory(node=project, target=Guid.load(test_wiki), user=self.non_contributor)
     url = '/{}comments/{}/'.format(API_BASE, comment._id)
     payload = self._set_up_payload(comment._id)
     res = self.app.put_json_api(url, payload, auth=self.non_contributor.auth)
     assert_equal(res.status_code, 200)
     assert_equal(payload['data']['attributes']['content'], res.json['data']['attributes']['content'])
开发者ID:baylee-d,项目名称:osf.io,代码行数:11,代码来源:test_comment_detail.py


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