On 29 September 2012 21:21, <span dir="ltr"><<a href="mailto:exarkun@twistedmatrix.com" target="_blank">exarkun@twistedmatrix.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 07:44 pm, <a href="mailto:poalman@gmail.com">poalman@gmail.com</a> wrote:<br>
><br>
>Thank you. I've made quite a bit of progress and now have my own<br>
>Portal,<br>
>CredentialsChecker, Realm, Shell, and FilePath object.<br>
><br>
>One thing I haven't been able to work out is, when I override, lets say<br>
>listdir for example in FilePath, I need to make a webcall to find out<br>
>the<br>
>folder contents, how can I make this call asynchronously?<br>
><br>
>I'm guessing I need to used deferred in someway, but seeing as listdir<br>
>doesn't return deferred objects I'm not sure how to make it work.<br>
><br>
>As listdir gets called from the Shell I guess I could change how<br>
>blocking<br>
>calls in my FilePath object get called?<br>
<br>
</div>The place to customize listing the contents of a directory is in the<br>
shell. More specifically, in an implementation of IFTPShell.list. It's<br>
almost certainly the case that you should *not* have a FilePath subclass<br>
with overridden methods. Instead, you should have a `list`<br>
implementation on your shell that returns the desired results. And<br>
since `IFTPShell.list` is allowed to return a Deferred, you no longer<br>
have a problem performing asynchronous operations.<br>
<br>
Jean-Paul<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div> That is likely a much better idea! Will I need to use some threading if I'm making web calls then from list? Presumably if I don't the whole process will block while it's waiting for web responses?</div>
<div><br></div><div>I've seen there is a deferToThread but I'm not too sure how to use it, do I just need to return it?</div></div>