def convert_id(obj_id_cls, obj_id): try: if isinstance(obj_id_cls, (SequenceField, IntField)): return int(obj_id) elif isinstance(obj_id_cls, (ObjectIdField)): return ObjectId(obj_id) else: return obj_id except ValueError: abort(400, origin='Invalid origin value type')
def get(self, origin_id, item_id): item = history_cls.objects.get_or_404(id=item_id) if str(item.origin.id) != origin_id: abort(404) return HistorySchema().dump(item).data