def share_project(project_id, usernames, read_only, share,**kwargs):
    """
        Share an entire project with a list of users, identifed by
        their usernames.

        The read_only flag ('Y' or 'N') must be set
        to 'Y' to allow write access or sharing.

        The share flat ('Y' or 'N') must be set to 'Y' to allow the
        project to be shared with other users
    """
    user_id = kwargs.get('user_id')

    proj_i = _get_project(project_id)

    #Is the sharing user allowed to share this project?
    proj_i.check_share_permission(int(user_id))

    user_id = int(user_id)

    for owner in proj_i.owners:
        if user_id == owner.user_id:
            break
    else:
       raise HydraError("Permission Denied. Cannot share project.")

    if read_only == 'Y':
        write = 'N'
        share = 'N'
    else:
        write = 'Y'

    if proj_i.created_by != user_id and share == 'Y':
        raise HydraError("Cannot share the 'sharing' ability as user %s is not"
                     " the owner of project %s"%
                     (user_id, project_id))

    for username in usernames:
        user_i = _get_user(username)

        proj_i.set_owner(user_i.id, write=write, share=share)

        for net_i in proj_i.networks:
            net_i.set_owner(user_i.id, write=write, share=share)
    db.DBSession.flush()
Share an entire project with a list of users, identifed by
        their usernames.

        The read_only flag ('Y' or 'N') must be set
        to 'Y' to allow write access or sharing.

        The share flat ('Y' or 'N') must be set to 'Y' to allow the
        project to be shared with other users