def rmdir(self, relpath): # We hook into rmdir in order to prevent users from deleting branches, # products and people from the VFS. virtual_url_fragment = self._abspath(relpath) path_segments = virtual_url_fragment.lstrip("/").split("/") # XXX: JonathanLange 2008-11-19 bug=300551: This code assumes stuff # about the VFS! We need to figure out the best way to delegate the # decision about permission-to-delete to the XML-RPC server. if len(path_segments) <= 3: return defer.fail(failure.Failure(PermissionDenied(virtual_url_fragment))) return AsyncVirtualTransport.rmdir(self, relpath)
def rename(self, rel_from, rel_to): # We hook into rename to catch the "unlock branch" event, so that we # can request a mirror once a branch is unlocked. abs_from = self._abspath(rel_from) if is_lock_directory(abs_from): deferred = self.server.branchChanged(abs_from) else: deferred = defer.succeed(None) deferred = deferred.addCallback( no_traceback_failures(lambda ignored: AsyncVirtualTransport.rename(self, rel_from, rel_to)) ) return deferred
def rmdir(self, relpath): # We hook into rmdir in order to prevent users from deleting branches, # products and people from the VFS. virtual_url_fragment = self._abspath(relpath) path_segments = virtual_url_fragment.lstrip('/').split('/') # XXX: JonathanLange 2008-11-19 bug=300551: This code assumes stuff # about the VFS! We need to figure out the best way to delegate the # decision about permission-to-delete to the XML-RPC server. if len(path_segments) <= 3: return defer.fail( failure.Failure(PermissionDenied(virtual_url_fragment))) return AsyncVirtualTransport.rmdir(self, relpath)
def rename(self, rel_from, rel_to): # We hook into rename to catch the "unlock branch" event, so that we # can request a mirror once a branch is unlocked. abs_from = self._abspath(rel_from) if is_lock_directory(abs_from): deferred = self.server.branchChanged(abs_from) else: deferred = defer.succeed(None) deferred = deferred.addCallback( no_traceback_failures(lambda ignored: AsyncVirtualTransport.rename( self, rel_from, rel_to))) return deferred
def mkdir(self, relpath, mode=None): # We hook into mkdir so that we can request the creation of a branch # and so that we can provide useful errors in the special case where # the user tries to make a directory like "~foo/bar". That is, a # directory that has too little information to be translated into a # Launchpad branch. deferred = AsyncVirtualTransport._getUnderylingTransportAndPath(self, relpath) @no_traceback_failures def maybe_make_branch_in_db(failure): # Looks like we are trying to make a branch. failure.trap(NoSuchFile) return self.server.createBranch(self._abspath(relpath)) @no_traceback_failures def real_mkdir((transport, path)): return getattr(transport, "mkdir")(path, mode) deferred.addCallback(real_mkdir) deferred.addErrback(maybe_make_branch_in_db) return deferred
def mkdir(self, relpath, mode=None): # We hook into mkdir so that we can request the creation of a branch # and so that we can provide useful errors in the special case where # the user tries to make a directory like "~foo/bar". That is, a # directory that has too little information to be translated into a # Launchpad branch. deferred = AsyncVirtualTransport._getUnderylingTransportAndPath( self, relpath) @no_traceback_failures def maybe_make_branch_in_db(failure): # Looks like we are trying to make a branch. failure.trap(NoSuchFile) return self.server.createBranch(self._abspath(relpath)) @no_traceback_failures def real_mkdir((transport, path)): return getattr(transport, 'mkdir')(path, mode) deferred.addCallback(real_mkdir) deferred.addErrback(maybe_make_branch_in_db) return deferred
def _transportFactory(self, url): return AsyncVirtualTransport(self, url)