Esempio n. 1
0
 def createCar(self, params):
     # construct a car object from the gathered data
     car = Car(params[0], params[1], params[2], params[3], params[4],
               params[5], params[6], params[7], params[8])
     # update the database with the new car and respond with a confirmation of insertion
     db.insertObject('cars', Car.attributesAsList(), car.asTuple())
     return jsonify({'car': car.asDict()}), 201
Esempio n. 2
0
 def updateCar(self, id, fieldsToUpdate, params):
     # update the car with the specified id, indicating which fields to update and what to update them to
     db.updateObject('cars', id, fieldsToUpdate, params)
     # retrieve the newly updated car and create an object from it's data
     carTuple = db.getObjectById('cars', id)[0]
     car = Car(carTuple[0], carTuple[1], carTuple[2], carTuple[3],
               carTuple[4], carTuple[5], carTuple[6], carTuple[7],
               carTuple[8])
     # jsonify the car to confirm the update
     return jsonify({'car': car.asDict()})