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.
This commit is contained in:
parent
21921dc8fc
commit
74445d0a1f
1 changed files with 5 additions and 2 deletions
|
@ -91,7 +91,7 @@ class GroupableMixin:
|
||||||
for parent in parents:
|
for parent in parents:
|
||||||
parent.add_children(children)
|
parent.add_children(children)
|
||||||
|
|
||||||
def add_child(self, member):
|
def _add_child(self, member):
|
||||||
self.assert_same_type(member)
|
self.assert_same_type(member)
|
||||||
|
|
||||||
if member == self:
|
if member == self:
|
||||||
|
@ -114,9 +114,12 @@ class GroupableMixin:
|
||||||
|
|
||||||
self.photodb._cached_tag_flat_dict = None
|
self.photodb._cached_tag_flat_dict = None
|
||||||
|
|
||||||
|
def add_child(self, member):
|
||||||
|
return self._add_child(member)
|
||||||
|
|
||||||
def add_children(self, members):
|
def add_children(self, members):
|
||||||
for member in members:
|
for member in members:
|
||||||
self.add_child(member)
|
self._add_child(member)
|
||||||
|
|
||||||
def assert_same_type(self, other):
|
def assert_same_type(self, other):
|
||||||
if not isinstance(other, type(self)):
|
if not isinstance(other, type(self)):
|
||||||
|
|
Loading…
Reference in a new issue