Пример #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()
Пример #2
0
 def post(self, id):
     try:
         patching.merge(id, g.identity.id)
         database.commit()
         return None, 204
     except patching.MergeError as e:
         return {'message': e.message}, 404
     except patching.UnmergeablePatchError as e:
         return {'message': e.message}, 400