Commit f9b3a342 authored by Pavel Spirek's avatar Pavel Spirek

Fixed bug when attempting to POST data with different namespace than parent node

parent 0eb55eef
...@@ -601,7 +601,7 @@ class BaseDatastore: ...@@ -601,7 +601,7 @@ class BaseDatastore:
# Get target schema node # Get target schema node
sn = n.schema_node # type: InternalNode sn = n.schema_node # type: InternalNode
member_sn = sn.get_child(input_member_name) member_sn = sn.get_child(input_member_name, input_member_ns)
if member_sn is None: if member_sn is None:
raise ValueError("Received json object contains unknown member") raise ValueError("Received json object contains unknown member")
...@@ -627,7 +627,8 @@ class BaseDatastore: ...@@ -627,7 +627,8 @@ class BaseDatastore:
# Create list if necessary # Create list if necessary
if existing_member is None: if existing_member is None:
existing_member = n.put_member(input_member_name, ArrayValue([])) new_member_name = input_member_name if n.namespace == input_member_ns else input_member_name_fq
existing_member = n.put_member(new_member_name, ArrayValue([]))
# Get ListNode key names # Get ListNode key names
list_node_keys = member_sn.keys # Key names in the form [(key, ns), ] list_node_keys = member_sn.keys # Key names in the form [(key, ns), ]
...@@ -677,7 +678,8 @@ class BaseDatastore: ...@@ -677,7 +678,8 @@ class BaseDatastore:
# Create leaf list if necessary # Create leaf list if necessary
if existing_member is None: if existing_member is None:
existing_member = n.put_member(input_member_name, ArrayValue([])) new_member_name = input_member_name if n.namespace == input_member_ns else input_member_name_fq
existing_member = n.put_member(new_member_name, ArrayValue([]))
# Convert input data from List/Dict to ArrayValue/ObjectValue # Convert input data from List/Dict to ArrayValue/ObjectValue
new_value_item = member_sn.entry_from_raw(input_member_value) new_value_item = member_sn.entry_from_raw(input_member_value)
...@@ -693,7 +695,8 @@ class BaseDatastore: ...@@ -693,7 +695,8 @@ class BaseDatastore:
if existing_member is None: if existing_member is None:
# Create new node (object member) # Create new node (object member)
new_member = n.put_member(input_member_name, input_member_value, raw=True) new_member_name = input_member_name if n.namespace == input_member_ns else input_member_name_fq
new_member = n.put_member(new_member_name, input_member_value, raw=True)
else: else:
# Data node already exists # Data node already exists
raise InstanceAlreadyPresent("Member \"{}\" already present in \"{}\"".format(input_member_name, ii)) raise InstanceAlreadyPresent("Member \"{}\" already present in \"{}\"".format(input_member_name, ii))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment