How can I bind user data to current ftp session?

30 views
Skip to first unread message

Michael Liao

unread,
Jul 25, 2011, 10:06:17 PM7/25/11
to Python FTP server library - Discussion group
Hi

I find a single username cannot store enough user data.

Is there any ftp session or context that can hold current user data?

Thanks!

Here is my RemoteAuthorizer that need access user info after
authentication:

class RemoteAuthorizer():

def validate_authentication(self, username, passwd):
userinfo = get_remote_userinfo(username, passwd);
if userinfo is None:
return False
# TODO: how to bind userinfo to current ftp session?
return True

def get_home_dir(self, username):
# TODO: how to get userinfo from current ftp session?
return '/nfs/users/%s' % userinfo.id

Giampaolo Rodolà

unread,
Jul 27, 2011, 6:49:55 AM7/27/11
to pyft...@googlegroups.com
Hi, 
I'm not sure what you mean exactly.
If you want to access the FTP session from the authorizer you just can't since in the autorizer you have no reference to the session handler (FTPHandler).
In this case you have to refactorize your code and move the logic from the authorizer to the handler.
Try to provide some more info about what you are trying to achieve exactly.

Regards,

- Giampaolo

Michael Liao

unread,
Jul 27, 2011, 8:33:25 PM7/27/11
to pyft...@googlegroups.com
Hi

I just want to know is there a way to bind some data to current ftp session like threadlocal?

For example when I use web.py to handle an http request with multiple processors, I can bind data to web.ctx in a processor and the post processors can get data from web.ctx. A web.ctx is sth. like a threadlocal. Does pyftpdlib provides such context in an ftp session?

Thanks!

--
You received this message because you are subscribed to the "Python FTP server library" project group:
http://code.google.com/p/pyftpdlib/
To post to this group, send email to pyft...@googlegroups.com
To unsubscribe from this group, send email to pyftpdlib-...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib



--
  Best regards,

Michael Liao

Giampaolo Rodolà

unread,
Jul 28, 2011, 4:01:55 AM7/28/11
to pyft...@googlegroups.com
>  is there a way to bind some data to current ftp session

No idea what this means. What data? What do you mean by "bind"?

> ...like threadlocal

Ditto

> For example when I use web.py to handle an http request with multiple processors
> I can bind data to web.ctx in a processor and the post processors can get data from web.ctx.
> A web.ctx is sth. like a threadlocal

?!?

Really, I have no clue as what you're asking, sorry.


- Giampaolo


2011/7/28 Michael Liao <askxu...@gmail.com>

Nick Craig-Wood

unread,
Jul 29, 2011, 5:50:25 AM7/29/11
to pyft...@googlegroups.com
On 28/07/11 09:01, Giampaolo Rodol� wrote:
>> is there a way to bind some data to current ftp session
>
> No idea what this means. What data? What do you mean by "bind"?

Subclassing the AbstractedFS is probably what you want to do - you can
then store your own data on a per session basis in there.

We had a slight problem because we needed to use the data from the
authorization phase to make the new AbstractedFS.

Take a look at

https://github.com/ncw/ftp-cloudfs/blob/master/ftpcloudfs/server.py

And you'll see how we did it. Not terribly elegant!

--
Nick Craig-Wood <ni...@craig-wood.com> -- http://www.craig-wood.com/nick

Michael Liao

unread,
Aug 4, 2011, 3:39:29 AM8/4/11
to Python FTP server library - Discussion group
Thanks!
> Nick Craig-Wood <n...@craig-wood.com> --http://www.craig-wood.com/nick
Reply all
Reply to author
Forward
0 new messages