Closed naman108 closed 5 months ago
This pull request defines a new decorator for nodes to define relationships similarly to how the property decorator is implemented.
This decorator can be used as follows:
from digitalpy.core.domain.relationship import Relationship, RelationshipType from digitalpy.core.domain.node import Node class Parent(Node): @Relationship(reltype=RelationshipType.ASSOCIATION, multiplicity_lower=2, multiplicity_upper=5) def children(self): return self._children @names.setter def children(self, value): self._children = value
This will restrict any more than five children or any less than two children from being added.
Navigability can be used as follows:
from digitalpy.core.domain.relationship import Relationship, RelationshipType from digitalpy.core.domain.node import Node class Parent(Node): @Relationship(reltype=RelationshipType.ASSOCIATION, navigable=False) def hidden(self): return self._hidden @hidden.setter def hidden(self, value): self._hidden = hidden
now the getter cannot be accessed so any operation such as print(parent_inst.hidden) would fail.
print(parent_inst.hidden)
Description
This pull request defines a new decorator for nodes to define relationships similarly to how the property decorator is implemented.
Functionality
This decorator can be used as follows:
This will restrict any more than five children or any less than two children from being added.
Navigability can be used as follows:
now the getter cannot be accessed so any operation such as
print(parent_inst.hidden)
would fail.