diff options
author | Robey Pointer <robey@lag.net> | 2004-12-19 19:43:27 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-12-19 19:43:27 +0000 |
commit | 8d127ae8e19551b9f4d10b66430e26fbe0caeb5b (patch) | |
tree | d83289fa2b0ebe6fb97943cabf396030ee364098 /paramiko/sftp_handle.py | |
parent | b2eb38483ca3cc7e64342c029cf17e203e915244 (diff) | |
download | paramiko-8d127ae8e19551b9f4d10b66430e26fbe0caeb5b.tar.gz |
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-134]
cleanup & docs in sftp
add some more docs to SFTPHandle, and give a default implementation for
close() that's usually right. add a flush() to the default implementation
of write(). document that symlink's args in the sftp protocol are out of
order (the spec is wrong).
Diffstat (limited to 'paramiko/sftp_handle.py')
-rw-r--r-- | paramiko/sftp_handle.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/paramiko/sftp_handle.py b/paramiko/sftp_handle.py index 5f202969..13f7b5bf 100644 --- a/paramiko/sftp_handle.py +++ b/paramiko/sftp_handle.py @@ -32,6 +32,9 @@ class SFTPHandle (object): Abstract object representing a handle to an open file (or folder) on the server. Each handle has a string representation used by the client to refer to the underlying file. + + Server implementations can (and should) subclass SFTPHandle to implement + features of a file handle, like L{stat} or L{chattr}. """ def __init__(self): self.__name = None @@ -44,8 +47,17 @@ class SFTPHandle (object): When a client closes a file, this method is called on the handle. Normally you would use this method to close the underlying OS level file object(s). + + The default implementation checks for attributes on C{self} named + C{readfile} and/or C{writefile}, and if either or both are present, + their C{close()} methods are called. This means that if you are + using the default implementations of L{read} and L{write}, this + method's default implementation should be fine also. """ - pass + if hasattr(self, 'readfile') and (self.readfile is not None): + self.readfile.close() + if hasattr(self, 'writefile') and (self.writefile is not None): + self.writefile.close() def read(self, offset, length): """ @@ -112,6 +124,7 @@ class SFTPHandle (object): self.writefile.seek(offset) self.__tell = offset self.writefile.write(data) + self.writefile.flush() except IOError, e: self.__tell = None return SFTPServer.convert_errno(e.errno) |