]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
remove mostly unneeded calls to conditional_post_update
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Apr 2010 18:16:07 +0000 (14:16 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Apr 2010 18:16:07 +0000 (14:16 -0400)
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/unitofwork.py

index aef297ee6c1ac27102660f36f8bdd89c872f91e8..1018c202955c73d128e11bd86c0c9c5ea6ba4a3f 100644 (file)
@@ -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)):
index 585188cfed7f334f3c638b241b9e2120c05b121f..ca8c31e8649d03132a706b829521a8a5994f0b1c 100644 (file)
@@ -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(