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