示例#1
0
    def aggregate_get(self, context, aggregate_id):
        query = model_query(context, models.Aggregate).filter_by(
            uuid=aggregate_id).options(joinedload("_metadata"))

        try:
            result = query.one()
        except NoResultFound:
            raise exception.AggregateNotFound(aggregate=aggregate_id)
        return result
示例#2
0
 def _do_update_aggregate(self, context, aggregate_id, values):
     with _session_for_write():
         query = model_query(context, models.Aggregate)
         query = add_identity_filter(query, aggregate_id)
         try:
             ref = query.with_lockmode('update').one()
         except NoResultFound:
             raise exception.AggregateNotFound(aggregate=aggregate_id)
         ref.update(values)
     return ref
示例#3
0
    def aggregate_destroy(self, context, aggregate_id):
        with _session_for_write():
            # First clean up all metadata related to this type
            meta_query = model_query(
                context,
                models.AggregateMetadata).filter_by(aggregate_id=aggregate_id)
            meta_query.delete()

            query = model_query(context,
                                models.Aggregate).filter_by(id=aggregate_id)

            count = query.delete()
            if count != 1:
                raise exception.AggregateNotFound(aggregate=aggregate_id)