'Reset the attributes of a tool_shed_repository that was previously installed.
The repository will be in some state other than INSTALLED, so all attributes
will be set to the default NEW state.  This will enable the repository to be
freshly installed.'

def reset_previously_installed_repository(self, repository):

    debug_msg = ("Resetting    tool_shed_repository    '%s'    for    installation.\n" % str(repository.name))
    debug_msg += 'The    current    state    of    the    tool_shed_repository    is:\n'
    debug_msg += ('deleted:    %s\n' % str(repository.deleted))
    debug_msg += ('tool_shed_status:    %s\n' % str(repository.tool_shed_status))
    debug_msg += ('uninstalled:    %s\n' % str(repository.uninstalled))
    debug_msg += ('status:    %s\n' % str(repository.status))
    debug_msg += ('error_message:    %s\n' % str(repository.error_message))
    log.debug(debug_msg)
    repository.deleted = False
    repository.tool_shed_status = None
    repository.uninstalled = False
    repository.status = self.app.install_model.ToolShedRepository.installation_status.NEW
    repository.error_message = None
    self.app.install_model.context.add(repository)
    self.app.install_model.context.flush()
