On Sun, 28 Dec 2008 11:52:56 +0000, Simply for IT email@example.com wrote:
I just have started to study twistedmatrix in my spare time couple of weeks ago. I am satisfied with the books, but as they are very terse, and they are not really FTP related, I could not figure out how the FTP is working.
I would like to be able to filter/modify the LIST(ing) process. Eg after list(ing) the result should not list any .py files even if they are there.
I have tried to look after IFTPShell, but no success sofar. Here is a code snipplet from the "official" testcases - or even from twisted.ftp)
IFTPShell is the way you control the behavior of the FTP server. To exclude certain results from a directory listing, you would implement the `list´ method so that it has the necessary logic for performing that exclusion.
def requestAvatar(self, avatarId, mind, *interfaces): for iface in interfaces: if iface is ftp.IFTPShell: avatar = ftp.FTPShell(filepath. FilePath(self.root)) return ftp.IFTPShell, avatar, getattr(avatar, 'logout', lambda: None)
Could anybody give me any advice, where to start, please?
You found an implementation of a realm which supports IFTPShell. If you aren't familiar with realms, read the cred documentation:
The realm is important but pretty simple. The avatar, the IFTPShell implementation, is what really controls the behavior you're interested in.