Exemple #1
0
 def put(self, id):
     """Update an application."""
     application = Application.query.filter_by(id=id).first_or_404()
     app.logger.info('Update application: %s' % id)
     target = Application.from_json(request.data)
     application.merge(target)
     db.session.commit()
     return application.to_json()
Exemple #2
0
 def post(self, id):
     """Create an application, expecting a json content."""
     application = Application.from_json(request.data)
     app.logger.info('Creating new application: %s' % request.data)
     db.session.add(application)
     try:
         db.session.commit()
     except IntegrityError, error:
         app.logger.warning(error)
         abort(409)