本文整理匯總了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