def write_reqs(rfpath, reqs):
    tmppath = rfpath + '.TMP'
    try:
        su.pickdump(reqs, tmppath)
    except:
        ryw.give_bad_news('fatal_error: write_reqs: pickdump failed: ' +
                          tmppath, logging.critical)
        return (False, tmppath, None)

    success,bakpath = ryw.make_tmp_file_permanent(tmppath, rfpath)
    if not success:
        return (False, tmppath, bakpath)

    logging.debug('write_reqs: file write succeeded.')
    return (True, tmppath, bakpath)
    def __write_to_disk(self):
        tmppath = self.reverseListsFile + '.TMP'
        try:
            su.pickdump(self.reverseDict, tmppath)
        except:
            ryw.give_bad_news('ReverseLists.add: pickdump failed.',
                              logging.critical)
            return False

        success,bakpath = ryw.make_tmp_file_permanent(
            tmppath, self.reverseListsFile)
        ryw.cleanup_path(tmppath, '_write_to_disk: cleanup, tmppath:')
        ryw.cleanup_path(bakpath, '_write_to_disk: cleanup, bakpath:')
        ryw.db_print('write_to_disk: written to disk...', 11)
        return success
    def modify(self, newMeta):
        logging.debug('modify: ' + repr(newMeta))

        tmpSearchFile = self._SearchFile__open_tmp_search_file()
        if not tmpSearchFile:
            self._SearchFile__cleanup()
            return False
            
        if not self._SearchFile__write_modified(tmpSearchFile, newMeta):
            self._SearchFile__cleanup()
            return False

        success,bakPath = ryw.make_tmp_file_permanent(
            self.searchfile + '_TMP', self.searchfile)

        if not self._SearchFile__modify_in_memory(newMeta):
            return False

        logging.debug('modify: done: ' + repr(newMeta))
        return True
    def delete(self, listToDelete):
        logging.debug('delete: ' + repr(listToDelete))
        
        tmpSearchFile = self._SearchFile__open_tmp_search_file()
        if not tmpSearchFile:
            self._SearchFile__cleanup()
            return False
            
        if not self._SearchFile__write_minus(tmpSearchFile, listToDelete):
            self._SearchFile__cleanup()
            return False

        success,bakPath = ryw.make_tmp_file_permanent(
            self.searchfile + '_TMP', self.searchfile)

        if not self._SearchFile__delete_from_memory(listToDelete):
            return False

        #logging.debug('delete: done: ' + repr(self.index))
        logging.debug('delete: done: ' + repr(listToDelete))
        return True