def openForWriting(self, path): path = [unicode(p) for p in path] if not path: raise ftp.PermissionDeniedError("cannot STOR to root directory") childname = path[-1] d = self._get_root(path) def _got_root((root, path)): if not path: raise ftp.PermissionDeniedError("cannot STOR to root directory") return root.get_child_at_path(path[:-1]) d.addCallback(_got_root) def _got_parent(parent): return WriteFile(parent, childname, self.convergence) d.addCallback(_got_parent) return d
def _got_root((root, path)): if not path: raise ftp.PermissionDeniedError( "cannot STOR to root directory") return root.get_child_at_path(path[:-1])
def _convert_error(f): f.trap(NoParentError) raise ftp.PermissionDeniedError("cannot delete root directory")