本文整理汇总了Python中tracim_backend.lib.core.content.ContentApi.delete方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.delete方法的具体用法?Python ContentApi.delete怎么用?Python ContentApi.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim_backend.lib.core.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_content
# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import delete [as 别名]
def delete_content(
self,
context,
request: TracimRequest,
hapic_data=None,
) -> None:
"""
Move a content to the trash. After that, the content will be invisible by default.
This action requires the user to be a content manager.
Note: the content is still accessible but becomes read-only.
"""
app_config = request.registry.settings['CFG']
path_data = hapic_data.path
api = ContentApi(
show_archived=True,
show_deleted=True,
current_user=request.current_user,
session=request.dbsession,
config=app_config,
)
content = api.get_one(
path_data.content_id,
content_type=content_type_list.Any_SLUG
)
with new_revision(
session=request.dbsession,
tm=transaction.manager,
content=content
):
api.delete(content)
return
示例2: delete_comment
# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import delete [as 别名]
def delete_comment(self, context, request: TracimRequest, hapic_data=None):
"""
Delete comment
"""
app_config = request.registry.settings['CFG']
api = ContentApi(
show_archived=True,
show_deleted=True,
current_user=request.current_user,
session=request.dbsession,
config=app_config,
)
wapi = WorkspaceApi(
current_user=request.current_user,
session=request.dbsession,
config=app_config,
)
workspace = wapi.get_one(hapic_data.path.workspace_id)
parent = api.get_one(
hapic_data.path.content_id,
content_type=content_type_list.Any_SLUG,
workspace=workspace
)
comment = api.get_one(
hapic_data.path.comment_id,
content_type=content_type_list.Comment.slug,
workspace=workspace,
parent=parent,
)
with new_revision(
session=request.dbsession,
tm=transaction.manager,
content=comment
):
api.delete(comment)
return
示例3: insert
# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import delete [as 别名]
#.........这里部分代码省略.........
parent=fruits_desserts_folder,
label='New Fruit Salad',
do_save=True,
)
old_fruit_salad = content_api.create(
content_type_slug=content_type_list.Page.slug,
workspace=recipe_workspace,
parent=fruits_desserts_folder,
label='Fruit Salad',
do_save=True,
do_notify=False,
)
with new_revision(
session=self._session,
tm=transaction.manager,
content=old_fruit_salad,
):
content_api.archive(old_fruit_salad)
content_api.save(old_fruit_salad)
bad_fruit_salad = content_api.create(
content_type_slug=content_type_list.Page.slug,
workspace=recipe_workspace,
parent=fruits_desserts_folder,
label='Bad Fruit Salad',
do_save=True,
do_notify=False,
)
with new_revision(
session=self._session,
tm=transaction.manager,
content=bad_fruit_salad,
):
content_api.delete(bad_fruit_salad)
content_api.save(bad_fruit_salad)
# File at the root for test
new_fruit_salad = content_api.create(
content_type_slug=content_type_list.Page.slug,
workspace=other_workspace,
label='New Fruit Salad',
do_save=True,
)
old_fruit_salad = content_api.create(
content_type_slug=content_type_list.Page.slug,
workspace=other_workspace,
label='Fruit Salad',
do_save=True,
)
with new_revision(
session=self._session,
tm=transaction.manager,
content=old_fruit_salad,
):
content_api.archive(old_fruit_salad)
content_api.save(old_fruit_salad)
bad_fruit_salad = content_api.create(
content_type_slug=content_type_list.Page.slug,
workspace=other_workspace,
label='Bad Fruit Salad',
do_save=True,
)
with new_revision(
session=self._session,
tm=transaction.manager,