Skip to content

reference

Canonical path: o6.reference

reference

reference(
    instance: None,
    referenceType: Any,
    /,
    *,
    inverse: bool = False,
) -> Any
reference(
    instance: _T,
    referenceType: Any,
    /,
    *,
    inverse: bool = False,
) -> _T
reference(
    subject: _T,
    referenceType: Any,
    object: Any,
    /,
    *,
    inverse: bool = False,
    server: Any = UNSET,
) -> _T
reference(
    subject,
    referenceType,
    object=UNSET,
    /,
    *,
    inverse=False,
    server=UNSET,
)

Describe a declarative linkage or add a reference between live nodes.

Two forms exist. o6.reference(instance, referenceType) attaches a node declaration to the type or Object that contains it through an arbitrary ReferenceType, and returns the same declaration so it can be assigned to a class attribute. o6.reference(source, referenceType, target) adds a reference between two live nodes immediately.

The named helpers -- o6.hasComponent, o6.hasProperty, o6.organizes and their inverses -- are this function bound to a standard ReferenceType. Reach for o6.reference for a custom or non-standard ReferenceType.

Parameters:

Name Type Description Default
subject _T | None

The node declaration to attach, the live source node of a two-ended reference, or None to describe the relationship without a target yet. None is only valid in the two-argument form.

required
referenceType Any

Any NodeId-like value or generated ReferenceType class.

required
object Any

The target of a two-ended reference. Live nodes are linked at once; a declaration becomes a child of the declaring type.

UNSET
inverse bool

Point the reference at the subject instead of away from it.

False
server Any

The server that owns a live reference. Only needed when neither endpoint is a live node and more than one server is running.

UNSET

Raises:

Type Description
TypeError

The subject is neither a node declaration nor a live node, the endpoints belong to different servers, server= is combined with the two-argument form, or a Method is attached with o6.hasProperty.

See Type child relationships for how declared children, optionality, and ownership fit together.