def post (self, name): """This method extends the RESTful convention to implement UPSERT""" q= session.query (Trip).filter_by (name=name) if q.count ()==0: # INSERT trip= Trip.fromJson (request.form['trip']) else: # UPDATE trip= q.first () trip.updatePoints (request.form['trip']) session.add (trip) session.commit () return trip.toJson (), 201, CORPSE
def post (self): # trip={ "name": "default", "points": [ [ 43.55277819471542, 6.934947967529298 ], [ 43.581136968065685, 6.942672729492188 ] ] } trip= Trip.fromJson (request.form['trip']) session.add (trip) session.commit () return trip.toJson (), 201, CORPSE