'Commit all of the relevant data to disk.  Do as much work
as possible without actually making the changes visible.'

def prepare_save(self):

    if self._save_prepared:
        raise Error(('save    of    %r    already    in    progress' % self._filename))
    if self._node_paths:
        (dir, name) = os.path.split(self._filename)
        (ffd, self._tmpname) = tempfile.mkstemp('.tmp', name, dir)
        try:
            try:
                f = os.fdopen(ffd, 'wb', 65536)
            except:
                os.close(ffd)
                raise
            try:
                cPickle.dump(self._node_paths, f, 2)
            finally:
                f.close()
                f = None
        except:
            tmpname = self._tmpname
            self._tmpname = None
            os.unlink(tmpname)
            raise
    self._save_prepared = True
