data = decode_json(web.ctx.data) App.validate(data) except Exception, e: return error_response(400, 'Data did not pass validation') try: app = App.collection.find_one({'_id': app_id, 'deleted': False}) except Exception, e: logging.error(e) return error_response(500, 'Server Error') if not app: message = 'App does not exist' logging.warn(message) return error_response(404, message) if not app.user_can_update(auth_user): message = 'App cannot be accessed by the user' logging.warn(message) return error_response(403, message) try: app.update(data) app.save() update_json = {'updated': app.updated_timestamp()} return encode_json(update_json) except Exception, e: logging.error(e) return error_response(500) @public_api_auth def DELETE(self, app_id, auth_user=None, auth_app_id=None):