本文整理汇总了Python中tracim.lib.content.ContentApi.get_one_by_label_and_parent方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.get_one_by_label_and_parent方法的具体用法?Python ContentApi.get_one_by_label_and_parent怎么用?Python ContentApi.get_one_by_label_and_parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.get_one_by_label_and_parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryFolder
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import get_one_by_label_and_parent [as 别名]
class HistoryFolder(Folder):
"""
A virtual resource which contains a sub-folder for every files (DAVNonCollection) contained in the parent
folder
"""
def __init__(self, path, environ, workspace: data.Workspace,
content: data.Content=None, type: str=HistoryType.Standard):
super(HistoryFolder, self).__init__(path, environ, workspace, content)
self._is_archived = type == HistoryType.Archived
self._is_deleted = type == HistoryType.Deleted
self.content_api = ContentApi(
current_user=self.user,
show_archived=self._is_archived,
show_deleted=self._is_deleted
)
def __repr__(self) -> str:
return "<DAVCollection: HistoryFolder (%s)>" % self.content.file_name
def getCreationDate(self) -> float:
return mktime(datetime.now().timetuple())
def getDisplayName(self) -> str:
return '.history'
def getLastModified(self) -> float:
return mktime(datetime.now().timetuple())
def getMember(self, content_label: str) -> _DAVResource:
content = self.content_api.get_one_by_label_and_parent(
content_label=content_label,
content_parent=self.content
)
return HistoryFileFolder(
path='%s/%s' % (self.path, content.get_label_as_file()),
environ=self.environ,
content=content)
def getMemberNames(self) -> [str]:
ret = []
content_id = None if self.content is None else self.content.id
for content in self.content_api.get_all(content_id, ContentType.Any, self.workspace):
if (self._is_archived and content.is_archived or
self._is_deleted and content.is_deleted or
not (content.is_archived or self._is_archived or content.is_deleted or self._is_deleted))\
and content.type != ContentType.Folder:
ret.append(content.get_label_as_file())
return ret
def createEmptyResource(self, name: str):
raise DAVError(HTTP_FORBIDDEN)
def createCollection(self, name: str):
raise DAVError(HTTP_FORBIDDEN)
def delete(self):
raise DAVError(HTTP_FORBIDDEN)
def handleDelete(self):
return True
def handleCopy(self, destPath: str, depthInfinity):
return True
def handleMove(self, destPath: str):
return True
def getMemberList(self) -> [_DAVResource]:
members = []
if self.content:
children = self.content.children
else:
children = self.content_api.get_all(False, ContentType.Any, self.workspace)
for content in children:
if content.is_archived == self._is_archived and content.is_deleted == self._is_deleted:
members.append(HistoryFileFolder(
path='%s/%s' % (self.path, content.get_label_as_file()),
environ=self.environ,
content=content))
return members