From 74445d0a1f100e28d9b69739c48bb685dfff11d4 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 12 Sep 2020 01:00:39 -0700 Subject: [PATCH] Add internal _add_child so that plural doesn't call transacted. add_children was calling add_child in a loop. Since this is a parent class, that call would actually call the subclasses' add_child method, which has a transaction decorator, and create unnecessary transactions. --- etiquette/objects.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 7694f4c..4f1cc48 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -91,7 +91,7 @@ class GroupableMixin: for parent in parents: parent.add_children(children) - def add_child(self, member): + def _add_child(self, member): self.assert_same_type(member) if member == self: @@ -114,9 +114,12 @@ class GroupableMixin: self.photodb._cached_tag_flat_dict = None + def add_child(self, member): + return self._add_child(member) + def add_children(self, members): for member in members: - self.add_child(member) + self._add_child(member) def assert_same_type(self, other): if not isinstance(other, type(self)):