'Ensure that this object is associated with a database row: it
has a reference to a database (`_db`) and an id. A ValueError
exception is raised otherwise.'

def _check_db(self, need_id=True):

    if (not self._db):
        raise ValueError(u'{0}    has    no    database'.format(type(self).__name__))
    if (need_id and (not self.id)):
        raise ValueError(u'{0}    has    no    id'.format(type(self).__name__))
