o6.namespaces.Namespaces¶
Manages custom OPC UA DataType namespaces for a client, server, or standalone (ownerless) context. Used it to register pre-built custom DataType namespaces or load NodeSet2 XML files before the client connects.
Type sharing semantics
- Clients share pre-built Namespaces directly —
append(namespace)links the same Namespace object (and its Python type classes) into the client. Multiple clients thatappend()the same pre-built Namespace will share a single set of type objects. - Servers always get their own copy —
append(namespace)rebuilds types from the saved original NodeIds with the server's actual namespace indices, producing a distinct Namespace. - Types built for a client are therefore not interchangeable with types built for a server (different namespace index spaces).
Important:
All append() calls on a client must happen before connect();
attempting to load after the client is connected raises RuntimeError.
Use pre-built namespaces when available:
client.ns.append(o6.ns.di) # or
server.ns.append(o6.ns.di)
This links the global prebuilt o6.ns.di namespace and reuses the
same type objects across clients.
For custom or external nodesets, load XML definitions first:
client.ns.load("path/to/custom_nodeset2.xml", short_name="MyTypes")
This parses the nodeset XML, builds Python type classes, and registers the namespace URI in the client's local table.
o6.namespaces.Namespaces ¶
Manages custom OPC UA DataType namespaces for a client, server, or standalone (ownerless) context. Used it to register pre-built custom DataType namespaces or load NodeSet2 XML files before the client connects.
Type sharing semantics
- Clients share pre-built Namespaces directly —
append(namespace)links the same Namespace object (and its Python type classes) into the client. Multiple clients thatappend()the same pre-built Namespace will share a single set of type objects. - Servers always get their own copy —
append(namespace)rebuilds types from the saved original NodeIds with the server's actual namespace indices, producing a distinct Namespace. - Types built for a client are therefore not interchangeable with types built for a server (different namespace index spaces).
Important
All append() calls on a client must happen before connect();
attempting to load after the client is connected raises RuntimeError.
Use pre-built namespaces when available:
client.ns.append(o6.ns.di) # or
server.ns.append(o6.ns.di)
This links the global prebuilt o6.ns.di namespace and reuses the
same type objects across clients.
For custom or external nodesets, load XML definitions first:
client.ns.load("path/to/custom_nodeset2.xml", short_name="MyTypes")
This parses the nodeset XML, builds Python type classes, and registers the namespace URI in the client's local table.
Functions¶
get_namespace ¶
Look up a loaded Namespace by short name, URI, or namespace index.
Raises KeyError if no matching Namespace is found.
append ¶
Append a namespace to the array (give it an index) and make it available under the shortname.
On a client
Registers the Namespace's canonical namespace URIs in the
client's local table and links the pre-built capsules. The
same Namespace (and type objects) is reused — no rebuild.
All append() calls must precede any manual
client.add_namespace() calls; otherwise the canonical
index slots may already be occupied and a ValueError is
raised.
On a server Creates a copy of the Namespace, restores its original (pre-remap) NodeIds, remaps them to the server's actual namespace indices, rebuilds the types, and links the new capsules. The returned Namespace is distinct from the input.
Raises ValueError if the namespace URI is already loaded in
this context.
load ¶
Load a nodeset from an XML file path. Returns the list of previously unknown namespaces from the nodeset that have been appended. Note that loading a nodeset might also add nodes to existing namespaces.
Parse the NodeSet2 XML, build Python type classes, and (if an owner is
set) register them with the owner. The returned Namespace stores the
built capsules and original NodeIds so it can later be passed to other
clients/servers via append(namespace).
Raises ValueError if the namespace URI is already loaded in
this context.