Looking at the test_xml_notification pytest added to test_models.py in my xml-improved fork of yangson.
Notice that it works okay when from_raw() is passed this object:
But not this (more common) object:
{
"testb:noA" : {
"leafO" : True
}
}
I understand that this is how Yangson generally works, but I wish that it were more like RESTCONF, whereby the object passed in and out of API calls has its top-level node being the node itself (not just it's contents).
The reason I care is because clients will always send notifications (i.e., via RFC 8040 SSE or the https-notif draft) with the top-level node existing, and all default-namespace settings are applied there. As it stands, the server-logic needs to float the default namespace down a level, without clobbering any already set default namespaces.
BTW, I tried toggling the allow_nodata boolean parameter, but it had no effect. To be honest, I'm still unclear what the allow_nodata is supposed to do. Maybe @HRogge can say? Is it, by chance, to allow exactly what I want (i.e., to toggle whether if the top-level node is included or not?)
FWIW, this issue also applies to InputNode and OutputNode, but they are both under RpcActionNode, whose from_raw() gives the expected behavior (i.e., a document with top-level node like {prefix}input. That said, it does also allow a document to have both an 'input' and 'output' simultaneously, a scenario that should never occur in normal operation.
Please respond quickly, as I'm hoping to get the xml-improved fork merged into master early next week. I'll submit a PR once I tidy up a few things, like adding a test_error pytest, etc.
Looking at the
test_xml_notificationpytest added totest_models.pyin myxml-improvedfork ofyangson.Notice that it works okay when from_raw() is passed this object:
But not this (more common) object:
I understand that this is how Yangson generally works, but I wish that it were more like RESTCONF, whereby the object passed in and out of API calls has its top-level node being the node itself (not just it's contents).
The reason I care is because clients will always send notifications (i.e., via RFC 8040 SSE or the
https-notifdraft) with the top-level node existing, and all default-namespace settings are applied there. As it stands, the server-logic needs to float the default namespace down a level, without clobbering any already set default namespaces.BTW, I tried toggling the
allow_nodataboolean parameter, but it had no effect. To be honest, I'm still unclear what theallow_nodatais supposed to do. Maybe @HRogge can say? Is it, by chance, to allow exactly what I want (i.e., to toggle whether if the top-level node is included or not?)FWIW, this issue also applies to
InputNodeandOutputNode, but they are both under RpcActionNode, whosefrom_raw()gives the expected behavior (i.e., a document with top-level node like{prefix}input. That said, it does also allow a document to have both an 'input' and 'output' simultaneously, a scenario that should never occur in normal operation.Please respond quickly, as I'm hoping to get the
xml-improvedfork merged into master early next week. I'll submit a PR once I tidy up a few things, like adding atest_errorpytest, etc.