'Raises an exception if fail is True and the entity doesn\'t exist
See also: The \'entity\' property.'

def getEntityByID(self, ID, fail=False):

    r = self.find(Or(Equal('DPID', ID), Equal(F('ID'), ID)))
    if (len(r) == 0):
        if fail:
            raise RuntimeError(('No    entity    with    ID    ' + str(ID)))
        else:
            return None
    assert (len(r) == 1)
    return r[0]
