Ignore:
Timestamp:
Apr 19, 2014, 7:13:39 PM (6 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Deliberately don't support pickling for `FTPHost` and `FTPFile`.

Problems with pickling (from ticket #75):

- To re-connect from the pickle file, you'd need the username and
  password, and I would understand if someone was mad at me if I
  didn't just use their password in memory but also wrote it to a
  file. ;-)

- The pickle file might be unpickled in a completely different
  environment. It might not be possible to connect to the host from
  there.

- The state of the FTP server might have changed between pickling and
  unpickling. For example, your last current directory might no longer
  exist. Of course, this can also happen during a session, but the
  more time passes between two logins (before pickling and when
  unpickling), the more likely a change on the remote side is.

- It gets much more complicated if there are open remote files when
  the FTPHost instance should be pickled.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/file.py

    r1459 r1482  
    1 # Copyright (C) 2003-2013, Stefan Schwarzer <sschwarzer@sschwarzer.net>
     1# Copyright (C) 2003-2014, Stefan Schwarzer <sschwarzer@sschwarzer.net>
    22# Copyright (C) 2008, Roger Demetrescu <roger.demetrescu@gmail.com>
    33# See the file LICENSE for licensing terms.
     
    1111
    1212import io
     13import pickle
    1314
    1415import ftputil.compat
     
    301302            # purposes.
    302303            self.closed = True
     304
     305    def __getstate__(self):
     306        raise pickle.PicklingError("pickling is deliberately unsupported")
Note: See TracChangeset for help on using the changeset viewer.