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


Python Deposition.save方法代码示例

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


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

示例1: add_submission_extra_data

# 需要导入模块: from invenio_deposit.models import Deposition [as 别名]
# 或者: from invenio_deposit.models.Deposition import save [as 别名]
def add_submission_extra_data(obj, eng):
    """ Add extra data to workflow object. """
    deposition = Deposition(obj)
    sip = deposition.get_latest_sip(sealed=True)
    metadata = sip.metadata
    submission_data = {}
    if "references" in metadata:
        submission_data["references"] = metadata["references"]
        del metadata["references"]
    if "extra_comments" in metadata:
        submission_data["extra_comments"] = metadata["extra_comments"]
        del metadata["extra_comments"]
    if "pdf" in metadata:
        submission_data["pdf"] = metadata["pdf"]
        del metadata["pdf"]
    obj.extra_data["submission_data"] = submission_data
    deposition.save()
开发者ID:jma,项目名称:inspire-next,代码行数:19,代码来源:tasks.py

示例2: migrate_workflow_object

# 需要导入模块: from invenio_deposit.models import Deposition [as 别名]
# 或者: from invenio_deposit.models.Deposition import save [as 别名]
def migrate_workflow_object(obj_id):
    try:
        obj = BibWorkflowObject.query.get(obj_id)
        rename_object_action(obj)
        if obj.workflow.name == "process_record_arxiv":
            metadata = obj.get_data()
            if isinstance(metadata, string_types):
                # Ignore records that have string as data
                return
            if 'drafts' in metadata:
                # New data model detected, just save and exit
                obj.save()
                return
            if hasattr(metadata, 'dumps'):
                metadata = metadata.dumps(clean=True)
            obj.data = bibfield.do(metadata)
            payload = Payload.create(
                type=obj.workflow.name,
                workflow_object=obj
            )
            payload.save()
        elif obj.workflow.name == "literature":
            d = Deposition(obj)
            sip = d.get_latest_sip()
            if sip:
                sip.metadata = bibfield.do(sip.metadata)
                sip.package = legacy_export_as_marc(hep2marc.do(sip.metadata))
                d.save()
        elif obj.workflow.name in ("authornew", "authorupdate"):
            data = obj.get_data()
            obj.set_data(author_bibfield.do(data))
            obj.save()
        else:
            obj.save()  # To update and trigger indexing
        reset_workflow_object_states(obj)
    except Exception as err:
        current_app.logger.error("Problem migrating record {0}".format(obj_id))
        current_app.logger.exception(err)
        msg = "Error: %r\n%s" % \
              (err, traceback.format_exc())
        obj.set_error_message(msg)
        obj.save(version=ObjectVersion.ERROR)
        raise
开发者ID:gitter-badger,项目名称:inspire-next,代码行数:45,代码来源:tasks.py


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