本文整理汇总了Python中invenio.modules.records.api.Record.values方法的典型用法代码示例。如果您正苦于以下问题:Python Record.values方法的具体用法?Python Record.values怎么用?Python Record.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio.modules.records.api.Record
的用法示例。
在下文中一共展示了Record.values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_description
# 需要导入模块: from invenio.modules.records.api import Record [as 别名]
# 或者: from invenio.modules.records.api.Record import values [as 别名]
def get_description(bwo):
"""Get the description (identifiers and categories) from the object data."""
from invenio.modules.records.api import Record
from flask import render_template, current_app
record = bwo.get_data()
final_identifiers = {}
try:
identifiers = Record(record.dumps()).persistent_identifiers
for values in identifiers.values():
final_identifiers.extend([i.get("value") for i in values])
except Exception:
current_app.logger.exception("Could not get identifiers")
if hasattr(record, "get"):
final_identifiers = [
record.get("system_control_number", {}).get("value", 'No ids')
]
else:
final_identifiers = []
categories = []
if hasattr(record, "get"):
if 'subject' in record:
lookup = ["subject", "term"]
elif "subject_term" in record:
lookup = ["subject_term", "term"]
else:
lookup = None
if lookup:
primary, secondary = lookup
category_list = record.get(primary, [])
if isinstance(category_list, dict):
category_list = [category_list]
categories = [subject[secondary] for subject in category_list]
return render_template('workflows/styles/harvesting_record.html',
categories=categories,
identifiers=final_identifiers)