def retrieve(self, identifier):
        """
        Retrieve a single rolled-up event.

        """
        container = self._retrieve_container(identifier)
        aggregate = self._aggregate()

        try:
            return self._to_model(
                aggregate,
                *self._filter(
                    self._rollup_query(
                        container,
                        aggregate,
                    ),
                    aggregate
                ).one(),
            )
        except NoResultFound as error:
            raise ModelNotFoundError(
                "{} not found".format(
                    self.container_type.__name__,
                ),
                error,
            )
示例#2
0
    def _retrieve(self, *criterion):
        """
        Retrieve a model by some criteria.

        :raises `ModelNotFoundError` if the row cannot be deleted.

        """
        try:
            return self._query(*criterion).one()
        except NoResultFound as error:
            raise ModelNotFoundError(error)
示例#3
0
async def person_update(person_id: UUID,
                        body: UpdatePersonSchema) -> PersonSchema:
    if person_id == PERSON_ID_1:
        person_1_copy = copy(PERSON_1)
        for key, value in body.dict().items():
            if value is None:
                continue
            setattr(person_1_copy, key, value)
        return person_1_copy.to_dict()
    else:
        raise ModelNotFoundError("{} not found".format(Person.__name__, ), )
示例#4
0
    def _retrieve(self, *criterion):
        """
        Retrieve a model by some criteria.

        :raises `ModelNotFoundError` if the row cannot be deleted.

        """
        try:
            return self._query(*criterion).one()
        except NoResultFound as error:
            raise ModelNotFoundError(
                "{} not found".format(self.model_class.__name__, ),
                error,
            )
示例#5
0
    async def _retrieve(self,
                        *criterion,
                        session: Optional[AsyncSession] = None):
        """
        Retrieve a model by some criteria.
        :raises `ModelNotFoundError` if the row cannot be deleted.
        """
        try:
            query = self._query(*criterion)
            async with self.with_maybe_session(session) as session:
                results = await session.execute(query)
                return results.one()[0]

        except NoResultFound as error:
            raise ModelNotFoundError(
                "{} not found".format(self.model_class.__name__, ),
                error,
            )
示例#6
0
async def person_retrieve(person_id: UUID) -> PersonSchema:
    if person_id == PERSON_ID_1:
        return PERSON_1.to_dict()
    else:
        raise ModelNotFoundError("{} not found".format(Person.__name__, ), )