Exemplo n.º 1
0
    def createEmptyResource(self, file_name: str):
        """
        [For now] we don't allow to create files right under workspaces.
        Though if we come to allow it, deleting the error's raise will make it possible.
        """
        # TODO : remove commentary here raise DAVError(HTTP_FORBIDDEN)
        if '/.deleted/' in self.path or '/.archived/' in self.path:
            raise DAVError(HTTP_FORBIDDEN)

        return FakeFileStream(file_name=file_name,
                              content_api=self.content_api,
                              workspace=self.workspace,
                              content=None,
                              parent=self.content,
                              path=self.path + '/' + file_name)
Exemplo n.º 2
0
    def createEmptyResource(self, file_name: str):
        """
        [For now] we don't allow to create files right under workspaces.
        Though if we come to allow it, deleting the error's raise will make it possible.
        """
        # TODO : remove commentary here raise DAVError(HTTP_FORBIDDEN)
        if '/.deleted/' in self.path or '/.archived/' in self.path:
            raise DAVError(HTTP_FORBIDDEN)

        content = None

        # Note: To prevent bugs, check here again if resource already exist
        path = os.path.join(self.path, file_name)
        resource = self.provider.getResourceInst(path, self.environ)
        if resource:
            content = resource.content

        return FakeFileStream(file_name=file_name,
                              content_api=self.content_api,
                              workspace=self.workspace,
                              content=content,
                              parent=self.content,
                              path=self.path + '/' + file_name)
Exemplo n.º 3
0
 def beginWrite(self, contentType: str = None) -> FakeFileStream:
     return FakeFileStream(content=self.content,
                           content_api=self.content_api,
                           file_name=self.content.get_label(),
                           workspace=self.content.workspace,
                           path=self.path)