[Twisted-Python] dynamic FTP realm

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sat Sep 29 16:21:49 EDT 2012

On 07:44 pm, poalman at gmail.com wrote:
>Thank you. I've made quite a bit of progress and now have my own 
>CredentialsChecker, Realm, Shell, and FilePath object.
>One thing I haven't been able to work out is, when I override, lets say
>listdir for example in FilePath, I need to make a webcall to find out 
>folder contents, how can I make this call asynchronously?
>I'm guessing I need to used deferred in someway, but seeing as listdir
>doesn't return deferred objects I'm not sure how to make it work.
>As listdir gets called from the Shell I guess I could change how 
>calls in my FilePath object get called?

The place to customize listing the contents of a directory is in the 
shell.  More specifically, in an implementation of IFTPShell.list.  It's 
almost certainly the case that you should *not* have a FilePath subclass 
with overridden methods.  Instead, you should have a `list` 
implementation on your shell that returns the desired results.  And 
since `IFTPShell.list` is allowed to return a Deferred, you no longer 
have a problem performing asynchronous operations.


More information about the Twisted-Python mailing list