class FileSaverMixin(SaverMixin):
    """Implements API for saving & loading in a File oriented context"""

    def __init__(self, pseudo, directory):
        SaverMixin.__init__(self, pseudo, directory)
    
    # MENU
    def save(self):
        """fill document with information from .profile file"""
        profile_file = open(self.get_id(), 'w')
        profile_file.write("#%s\n"% self.encoding)
        self.config.write(profile_file)
        profile_file.close()
        
    def load(self,):
        """fill document with information from .profile file"""
        # load profile
        if not os.path.exists(self.get_id()):
            print "profile %s does not exists"% self.get_id()
            return False
        else:
            profile_file = open(self.get_id())
            self.encoding = profile_file.readline()[1:]
            self.config = CustomConfigParser(self.encoding)
            self.config.readfp(profile_file)
            profile_file.close()
            return True

    def to_stream(self):
        """returns a file object containing values"""
        file_obj = tempfile.TemporaryFile()
        file_obj.write("#%s\n"% self.encoding)
        self.config.write(file_obj)
        file_obj.seek(0)
        return file_obj