Ejemplo n.º 1
0
def load_data(datafile):
    with app.app_context():
        with open(datafile) as f:
            data = json.load(f)
        user_id = "initial-data-loader"
        patch = JsonPatch.from_diff({}, data)
        patch_request_id = patching.create_request(patch, user_id)
        patching.merge(patch_request_id, user_id)
        database.commit()
Ejemplo n.º 2
0
 def patch(self):
     try:
         patch_request_id = patching.create_request(
             patching.from_text(request.data), g.identity.id)
         database.commit()
         return None, 202, {
             'Location': api.url_for(PatchRequest, id=patch_request_id)
         }
     except patching.InvalidPatchError as e:
         return {'status': 400, 'message': str(e)}, 400
Ejemplo n.º 3
0
 def patch(self):
     try:
         patch_request_id = patching.create_request(
             JsonPatch(parse_json(request)), g.identity.id)
         database.commit()
         return None, 202, {
             'Location': url_for('patchrequest', id=patch_request_id)
         }
     except ResourceError as e:
         return e.response()
     except patching.InvalidPatchError as e:
         return {'status': 400, 'message': str(e)}, 400