modified: netbox_services/engine/__init__.py

modified:   netbox_services/engine/allocators.py
modified:   netbox_services/engine/context.py
new file:   netbox_services/engine/mappers.py
modified:   netbox_services/engine/resolver.py
new file:   netbox_services/engine/templating.py
modified:   netbox_services/forms.py
modified:   netbox_services/models.py
modified:   netbox_services/tests/test_allocators.py
new file:   netbox_services/tests/test_mappers.py
modified:   netbox_services/tests/test_resolver.py
new file:   netbox_services/tests/test_templating.py
Simplify layout to template and service instances
This commit is contained in:
sven committed 2026-08-17 15:12:42 +02:00
1 parent 4ff9eac274
commit b1c9c7a40b
12 files changed
+1133 -33

No files matched your search

+11 -4
View File
@@ -1,22 +1,29 @@
"""Resolution context — carries service and parent references during tree walk."""
"""Resolution context — carries service and ancestor chain during tree walk."""
class Context:
"""Evaluation frame for the resolver.
Top-level context has ``service`` set and ``parent_object`` as None.
Top-level context has ``service`` set, ``parent_object`` as None,
and ``ancestors`` as an empty list.
Each selected/allocated object pushes a child context so children
can reference ``parent`` and traverse its relations.
can reference ``parent`` (immediate) and ``ancestors`` (full chain).
``ancestors[0]`` is the immediate parent (``p1`` in Jinja2),
``ancestors[1]`` is the grandparent (``p2``), etc.
"""
def __init__(self, service, parent_object=None):
def __init__(self, service, parent_object=None, ancestors=None):
self.service = service
self.parent_object = parent_object
self.ancestors = ancestors if ancestors is not None else []
def child(self, obj):
return Context(
service=self.service,
parent_object=obj,
ancestors=[obj] + self.ancestors,
)
@property