I need to implement an abstract model using Spyne.
In fact, let's say - as a simple example - that I want to manage a garage business.
I then have the following classes:
class Vehicle(ComplexModel):
''' this class is abstract '''
_type_info = [
('owner',Unicode)
]
class Car(Vehicle):
_type_info = [
('color',Unicode),
('speed',Integer)
]
class Bike(Vehicle):
_type_info = [
('size',Integer)
]
class Garage(ComplexModel):
_type_info = [
('vehicles',Array(Vehicle))
]
When I want to get all vehicles managed by my garage, I will only get their Vehicle properties (aka owner here), and not the other ones.
Is there a way to manage abstract objects with Spyne?
Of course, a simple approach would be to have:
class Garage(ComplexModel):
_type_info = [
('bikes',Array(Bike)),
('cars',Array(Car))
]
but I don't like it: if I do that, I'll have to change my "Garage" class everytime I create a new Vehicle class... I want my Garage class to manage Vehicles, no matter what type of Vehicles it is. Is it possible?