本文整理汇总了Python中tracim.model.data.Content.extract_links_from_content方法的典型用法代码示例。如果您正苦于以下问题:Python Content.extract_links_from_content方法的具体用法?Python Content.extract_links_from_content怎么用?Python Content.extract_links_from_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.model.data.Content
的用法示例。
在下文中一共展示了Content.extract_links_from_content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: serialize_node_for_page
# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import extract_links_from_content [as 别名]
def serialize_node_for_page(content: Content, context: Context):
if content.type in (ContentType.Page, ContentType.File) :
data_container = content
# The following properties are overriden by revision values
if content.revision_to_serialize>0:
for revision in content.revisions:
if revision.revision_id==content.revision_to_serialize:
data_container = revision
break
result = DictLikeClass(
id=content.content_id,
parent=context.toDict(content.parent),
workspace=context.toDict(content.workspace),
type=content.type,
is_new=content.has_new_information_for(context.get_user()),
content=data_container.description,
created=data_container.created,
label=data_container.label,
icon=ContentType.get_icon(content.type),
owner=context.toDict(data_container.owner),
status=context.toDict(data_container.get_status()),
links=context.toDict(content.extract_links_from_content(data_container.description)),
revisions=context.toDict(sorted(content.revisions, key=lambda v: v.created, reverse=True)),
selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
urls = context.toDict({
'mark_read': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_read', content)),
'mark_unread': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_unread', content))
})
)
if content.type==ContentType.File:
result.label = content.label if content.label else content.file_name
result['file'] = DictLikeClass(
name = data_container.file_name,
size = len(data_container.file_content),
mimetype = data_container.file_mimetype)
return result
if content.type==ContentType.Folder:
value = DictLikeClass(
id=content.content_id,
label=content.label,
is_new=content.has_new_information_for(context.get_user()),
)
return value
raise NotImplementedError