Hi Paul -<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">I'm very new to twisted (I've only just started using it, so I apologise if<br></span><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">anything I ask is seemingly obvious!).</span><br style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">I'm looking to try and set up a FTP server which will serve a file<br></span><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">structure and files which don't exists on the server (the file structure<br>
</span><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">information is stored on cassandra, and the files are on s3). The file<br></span><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">structure and files will also be unique to the user, so different logins<br>
</span><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">will generate the file structure for that particular user, but I guess I<br></span><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">can adress that later.</span></blockquote>
</blockquote><div><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></span></div><div><br></div><div><font color="#222222" face="arial, sans-serif">Here is a quick sketch of some of the steps ... but beware, I haven't debugged this. You'll want to subclass twisted.protocols.ftp.FTPShell with a new command interpreter</font></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif"> class PaulsFTPShell(FTPShell):</font></div><div><font color="#222222" face="arial, sans-serif"> ....</font></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">The you'll need to write a Realm that returns an instance of your FTP Shell:</font></div><div><font color="#222222" face="arial, sans-serif"><br>
</font></div><div><font color="#222222" face="arial, sans-serif"><div>class PaulsFTPRealm(FTPRealm):</div><div> """</div><div> @type anonymousRoot: L{twisted.python.filepath.FilePath}</div><div> @ivar anonymousRoot: Root of the filesystem to which anonymous</div>
<div> users will be granted access.</div><div> """</div><div> implements(portal.IRealm)</div><div><br></div><div> def __init__(self, ....)</div><div> ....</div><div><br></div><div> def requestAvatar(self, avatarId, mind, *interfaces):</div>
<div> for iface in interfaces:</div><div> if iface is IFTPShell:</div><div> if avatarId is checkers.ANONYMOUS:</div><div> avatar = None</div><div> else:</div>
<div> avatar = PaulsFTPShell( ...)</div><div><br></div><div> return IFTPShell, avatar, getattr(avatar, 'logout', lambda: None)</div><div> raise NotImplementedError("Only IFTPShell interface is supported by this realm")</div>
<div><br></div></font></div><div><br></div><div>Then you'll stich it all together like this:</div><div><br></div><div><br></div><div><font color="#222222" face="arial, sans-serif"> f = FTPFactory()</font></div><div>
<font color="#222222" face="arial, sans-serif"> r = PaulsFTPRealm()</font></div>
<div><font color="#222222" face="arial, sans-serif"> p = Portal.Portal(r)</font></div><div><font color="#222222" face="arial, sans-serif"> p.registerChecker(...)</font></div><div><font color="#222222" face="arial, sans-serif"><br>
</font></div><div><font color="#222222" face="arial, sans-serif"> f.portal = p</font></div><div><br></div><div><font color="#222222" face="arial, sans-serif">Hope this helps get you started.</font></div><div><font color="#222222" face="arial, sans-serif"><br>
</font></div>