From 376b8276f0a7acb1f95313ca604e273d7c981f57 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 6 Apr 2010 14:16:07 -0400 Subject: [PATCH] remove mostly unneeded calls to conditional_post_update --- lib/sqlalchemy/orm/dependency.py | 47 +++++++++++++++++--------------- lib/sqlalchemy/orm/unitofwork.py | 5 ++++ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index aef297ee6c..1018c20295 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -271,15 +271,14 @@ class DependencyProcessor(object): else: return False - def _conditional_post_update(self, state, uowcommit, related): - if state is not None and self.post_update: - for x in related: - if x is not None: - uowcommit.issue_post_update( - state, - [r for l, r in self.prop.synchronize_pairs] - ) - break + def _post_update(self, state, uowcommit, related): + for x in related: + if x is not None: + uowcommit.issue_post_update( + state, + [r for l, r in self.prop.synchronize_pairs] + ) + break def _pks_changed(self, uowcommit, state): raise NotImplementedError() @@ -434,7 +433,8 @@ class OneToManyDP(DependencyProcessor): state, child, None, True, uowcommit) - self._conditional_post_update( + if self.post_update and child: + self._post_update( child, uowcommit, [state]) @@ -445,7 +445,8 @@ class OneToManyDP(DependencyProcessor): state, child, None, True, uowcommit) - self._conditional_post_update( + if self.post_update and child: + self._post_update( child, uowcommit, [state]) @@ -456,8 +457,8 @@ class OneToManyDP(DependencyProcessor): if history: for child in history.added: self._synchronize(state, child, None, False, uowcommit) - if child is not None: - self._conditional_post_update( + if child is not None and self.post_update: + self._post_update( child, uowcommit, [state]) @@ -611,12 +612,13 @@ class ManyToOneDP(DependencyProcessor): # before we can DELETE the row for state in states: self._synchronize(state, None, None, True, uowcommit) - history = uowcommit.get_attribute_history( - state, - self.key, - passive=self.passive_deletes) - if history: - self._conditional_post_update( + if state and self.post_update: + history = uowcommit.get_attribute_history( + state, + self.key, + passive=self.passive_deletes) + if history: + self._post_update( state, uowcommit, history.sum()) @@ -628,9 +630,10 @@ class ManyToOneDP(DependencyProcessor): for child in history.added: self._synchronize(state, child, None, False, uowcommit) - self._conditional_post_update( - state, - uowcommit, history.sum()) + if self.post_update: + self._post_update( + state, + uowcommit, history.sum()) def _synchronize(self, state, child, associationrow, clearkeys, uowcommit): if state is None or (not self.post_update and uowcommit.is_deleted(state)): diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index 585188cfed..ca8c31e864 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -221,6 +221,11 @@ class UOWTransaction(object): ] ).difference(cycles) + #sort = topological.sort(self.dependencies, postsort_actions) + #print "--------------" + #print self.dependencies + #print postsort_actions + # execute if cycles: for set_ in topological.sort_as_subsets( -- 2.47.3