本文整理汇总了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()
示例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