Skip to content
Snippets Groups Projects
Commit 62dcb5e8 authored by Andrew Kapuscinski's avatar Andrew Kapuscinski
Browse files

WS-705: corrected version.parameters for sqlalchemy updates with deepcopy

parent b3014868
No related branches found
No related tags found
1 merge request!733WS-705: corrected version.parameters for sqlalchemy updates with deepcopy
Pipeline #4087 passed
......@@ -19,6 +19,8 @@
File containing definitions for the capability version routes of the Workspaces REST API
"""
import copy
import requests
from pycapo import CapoConfig
from pyramid.httpexceptions import (
......@@ -270,8 +272,15 @@ def change_srdp_compatibility_version_metadata(request: Request) -> Response:
archive_url = settings.locatorServiceUrlPrefix
# split the locatorServiceUrlPrefix to get url without /location?
archive_url = archive_url.split("/location?")
version.parameters["metadata"]["is_srdp"] = request.json_body
change_srdp_url = archive_url[0] + f"/is_srdp?locator={version.parameters['product_locator']}"
# sqlalchemy does not detect in-place mutations of JSON
# https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.JSON
# to get past this we use a deepcopy of version.parameters to create a "new" JSON obj
version.parameters = copy.deepcopy(version.parameters)
# we then update the "new" deepcopy version.parameters
version.parameters["metadata"]["is_srdp"] = request.json_body
r = requests.post(change_srdp_url, json=request.json_body)
if r.status_code != requests.codes.ok:
srdp_change_failed_msg = f"SRDP-Compatibility change failed: {r.status_code}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment