本文整理汇总了Python中tracim_backend.lib.core.content.ContentApi.copy_children方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.copy_children方法的具体用法?Python ContentApi.copy_children怎么用?Python ContentApi.copy_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim_backend.lib.core.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.copy_children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileResource
# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import copy_children [as 别名]
#.........这里部分代码省略.........
new_filename = webdav_convert_file_name_to_bdd(basename(destpath))
regex_file_extension = re.compile(
'(?P<label>.*){}'.format(
re.escape(self.content.file_extension)))
same_extension = regex_file_extension.match(new_filename)
if same_extension:
new_label = same_extension.group('label')
new_file_extension = self.content.file_extension
else:
new_label, new_file_extension = os.path.splitext(
new_filename)
self.content_api.update_content(
self.content,
new_label=new_label,
)
self.content.file_extension = new_file_extension
self.content_api.save(self.content)
# INFO - G.M - 2018-03-09 - Moving file if needed
destination_workspace = self.tracim_context.candidate_workspace
try:
destination_parent = self.tracim_context.candidate_parent_content
except ContentNotFound:
destination_parent = None
if destination_parent != parent or destination_workspace != workspace: # nopep8
# INFO - G.M - 12-03-2018 - Avoid moving the file "at the same place" # nopep8
# if the request does not result in a real move.
self.content_api.move(
item=self.content,
new_parent=destination_parent,
must_stay_in_same_workspace=False,
new_workspace=destination_workspace
)
except TracimException as exc:
raise DAVError(HTTP_FORBIDDEN) from exc
transaction.commit()
def copyMoveSingle(self, destpath, isMove):
if isMove:
# INFO - G.M - 12-03-2018 - This case should not happen
# As far as moveRecursive method exist, all move should not go
# through this method. If such case appear, try replace this to :
####
# self.move_file(destpath)
# return
####
raise NotImplemented('Feature not available')
destpath = normpath(destpath)
self.tracim_context.set_destpath(destpath)
try:
can_move_content.check(self.tracim_context)
except TracimException as exc:
raise DAVError(HTTP_FORBIDDEN)
new_filename = webdav_convert_file_name_to_bdd(basename(destpath))
regex_file_extension = re.compile(
'(?P<label>.*){}'.format(re.escape(self.content.file_extension)))
same_extension = regex_file_extension.match(new_filename)
if same_extension:
new_label = same_extension.group('label')
new_file_extension = self.content.file_extension
else:
new_label, new_file_extension = os.path.splitext(new_filename)
self.tracim_context.set_destpath(destpath)
destination_workspace = self.tracim_context.candidate_workspace
try:
destination_parent = self.tracim_context.candidate_parent_content
except ContentNotFound as e:
destination_parent = None
workspace = self.content.workspace
parent = self.content.parent
try:
new_content = self.content_api.copy(
item=self.content,
new_label=new_label,
new_file_extension=new_file_extension,
new_parent=destination_parent,
new_workspace=destination_workspace
)
self.content_api.copy_children(self.content, new_content)
except TracimException as exc:
raise DAVError(HTTP_FORBIDDEN) from exc
transaction.commit()
def supportRecursiveMove(self, destpath):
return True
@webdav_check_right(is_content_manager)
def delete(self):
ManageActions(
action_type=ActionDescription.DELETION,
api=self.content_api,
content=self.content,
session=self.session,
).action()