def createCollection(self, name): """Create a new collection as member of self. See DAVResource.createCollection() """ assert not "/" in name if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) fp = self.provider._locToFilePath(path) os.mkdir(fp)
def createEmptyResource(self, name): """Create an empty (length-0) resource. See DAVResource.createEmptyResource() """ assert not "/" in name if self.provider.readonly: raise DAVError(HTTP_FORBIDDEN) path = util.joinUri(self.path, name) fp = self.provider._locToFilePath(path) f = open(fp, "w") f.close() return self.provider.getResourceInst(path, self.environ)
def getMember(self, name): """Return direct collection member (DAVResource or derived). See DAVCollection.getMember() """ fp = os.path.join(self._filePath, name.decode("utf8")) # name = name.encode("utf8") path = util.joinUri(self.path, name) if os.path.isdir(fp): res = FolderResource(path, self.environ, fp) elif os.path.isfile(fp): res = FileResource(path, self.environ, fp) else: _logger.debug("Skipping non-file %s" % fp) res = None return res
def getMember(self, name): """Return direct collection member (DAVResource or derived). See DAVCollection.getMember() """ pathComponents = self.path.strip("/").split("/") if len(pathComponents)<=1: fp = os.path.join(self._filePath, name.split(" - ")[0].decode("utf8")) else: fp = os.path.join(self._filePath, name.decode("utf8")) name = name.encode("utf8") path = util.joinUri(self.path, name) if os.path.isdir(fp): res = FolderResource(path, self.environ, fp) elif os.path.isfile(fp): res = FileResource(path, self.environ, fp) else: _logger.debug("Skipping non-file %s" % fp) res = None return res