def get_entry(entry):
    """ Helper function to get an entry by ID or by object """

    if hasattr(entry, 'id'):
        return entry

    if isinstance(entry, (int, str)):
        return model.Entry.get(id=int(entry))
    raise ValueError("entry is of unknown type {}".format(type(entry)))