def gather_records(file):
    """Gather up the set of database records that another Librarian will need if
    we're to upload *file* to it.

    Right now this function is fairly simple because the relevant code only
    works with one file at a time. You could imagine extending this function
    to take a list of files and gather all of the records at once, which might
    lead to a little bit less redundancy.

    """
    info = {}
    info['files'] = {file.name: file.to_dict()}

    if file.obsid is not None:
        obs = file.observation
        info['observations'] = {obs.obsid: obs.to_dict()}

        sess = obs.session
        if sess is not None:
            info['sessions'] = {sess.id: sess.to_dict()}

    return info