code: def write(self, file_or_filename):
          
          if isinstance(file_or_filename, basestring):
              file = None
              try:
                  file = open(file_or_filename, "wb")
              except Exception, detail:
                  logger.error("Error opening %s." % detail)
              finally:
                  if file is not None:
                      self._write_data(file)
                      file.close()
          else:
              file = file_or_filename
              self._write_data(file)
  
          return file
docs: Writes the case data to file.