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


Python OsfStorageFolder.get方法代码示例

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


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

示例1: wrapped

# 需要导入模块: from addons.osfstorage.models import OsfStorageFolder [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFolder import get [as 别名]
    def wrapped(payload, *args, **kwargs):
        try:
            user = OSFUser.load(payload['user'])
            dest_node = AbstractNode.load(payload['destination']['node'])
            source = OsfStorageFileNode.get(payload['source'], kwargs['node'])
            dest_parent = OsfStorageFolder.get(payload['destination']['parent'], dest_node)

            kwargs.update({
                'user': user,
                'source': source,
                'destination': dest_parent,
                'name': payload['destination']['name'],
            })
        except KeyError:
            raise HTTPError(httplib.BAD_REQUEST)

        return func(*args, **kwargs)
开发者ID:geeksnglitter,项目名称:osf.io,代码行数:19,代码来源:decorators.py

示例2: post

# 需要导入模块: from addons.osfstorage.models import OsfStorageFolder [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFolder import get [as 别名]
    def post(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data, context=self.get_serializer_context())
        if serializer.is_valid():
            source = serializer.validated_data.pop('source')
            destination = serializer.validated_data.pop('destination')
            name = destination.get('name')
            dest_target = self.get_target(target_id=destination.get('target'))
            try:
                source = OsfStorageFileNode.get(source, self.get_object())
            except OsfStorageFileNode.DoesNotExist:
                raise NotFound

            try:
                dest_parent = OsfStorageFolder.get(destination.get('parent'), dest_target)
            except OsfStorageFolder.DoesNotExist:
                raise NotFound
            serializer.save(source=source, destination=dest_parent, name=name)
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:erinspace,项目名称:osf.io,代码行数:21,代码来源:views.py

示例3: wrapped

# 需要导入模块: from addons.osfstorage.models import OsfStorageFolder [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFolder import get [as 别名]
    def wrapped(payload, *args, **kwargs):
        try:
            user = OSFUser.load(payload['user'])
            # Waterbutler is sending back ['node'] under the destination payload - WB should change to target
            target = payload['destination'].get('target') or payload['destination'].get('node')
            dest_target = Guid.load(target).referent
            source = OsfStorageFileNode.get(payload['source'], kwargs['target'])
            dest_parent = OsfStorageFolder.get(payload['destination']['parent'], dest_target)

            kwargs.update({
                'user': user,
                'source': source,
                'destination': dest_parent,
                'name': payload['destination']['name'],
            })
        except KeyError:
            raise HTTPError(httplib.BAD_REQUEST)

        return func(*args, **kwargs)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:21,代码来源:decorators.py


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