policies: fix error when error occurs during policy process with no target
This commit is contained in:
parent
8beddcddb0
commit
7ff679b1a3
|
@ -82,8 +82,10 @@ class PolicyEngine:
|
|||
|
||||
def _iter_bindings(self) -> Iterator[PolicyBinding]:
|
||||
"""Make sure all Policies are their respective classes"""
|
||||
return PolicyBinding.objects.filter(target=self.__pbm, enabled=True).order_by(
|
||||
"order"
|
||||
return (
|
||||
PolicyBinding.objects.filter(target=self.__pbm, enabled=True)
|
||||
.order_by("order")
|
||||
.iterator()
|
||||
)
|
||||
|
||||
def _check_policy_type(self, policy: Policy):
|
||||
|
|
|
@ -64,7 +64,10 @@ class PolicyBinding(SerializerModel):
|
|||
return PolicyBindingSerializer
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Policy Binding {self.target} #{self.order} {self.policy}"
|
||||
try:
|
||||
return f"Policy Binding {self.target} #{self.order} {self.policy}"
|
||||
except PolicyBinding.target.RelatedObjectDoesNotExist: # pylint: disable=no-member
|
||||
return f"Policy Binding - #{self.order} {self.policy}"
|
||||
|
||||
class Meta:
|
||||
|
||||
|
|
Reference in New Issue