def for_name(cls, name, create=False): try: return Session.query(cls).filter_by(name=name).one() except NoResultFound: if create: return returnit(Session.add, cls(name)) else: raise EventNotFound(name)
def track(self, *args, **kwargs): return returnit(self._entries.append, Entry(*args, **kwargs))