'Create a new history and associate it with the current session and
its associated user (if set).'

def new_history(self, name=None):

    history = self.app.model.History()
    if name:
        history.name = name
    history.add_galaxy_session(self.galaxy_session)
    self.galaxy_session.current_history = history
    if self.galaxy_session.user:
        history.user = self.galaxy_session.user
    history.genome_build = self.app.genome_builds.default_value
    self.app.security_agent.history_set_default_permissions(history)
    self.sa_session.add_all((self.galaxy_session, history))
    self.sa_session.flush()
    return history
