def show(city_id): schema = CitySchema() city = City.get(id=city_id) if not city: abort(404) return schema.dumps(city)
def delete(city_id): city = City.get(id=city_id) if not city: abort(404) city.delete() db.commit() return '', 204
def update(city_id): schema = CitySchema() city = City.get(id=city_id) if not city: abort(404) try: data = schema.load(request.get_json()) city.set(**data) db.commit() except ValidationError as err: return jsonify({ 'message': 'Validation failed', 'errors': err.messages }), 422 return schema.dumps(city)