Skip to content

Notification.from_raw() difficult to use. #78

Description

@kwatsen

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:

{
    "testb:leafO" : True
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions