def extract_ids(objects_or_ids):
    """Return a list of ids given either objects with ids or a list of ids."""
    try:
        ids = [obj.id for obj in objects_or_ids]
    except:
        ids = objects_or_ids
    return ids