I reported the bug a year ago. It seems nobody is interested in fixing
it.
So, this is my first try, but i don't know how to use the regression
test to see if it is correct. Can anybody help me?
unitofwork.py:
class UOWExecutor(object):
"""Encapsulates the execution traversal of a UOWTransaction
structure."""
def execute(self, trans, tasks, isdelete=None):
self._nonrecursive_stack=[]
self._nonrecursive_stack.append(('E', trans, tasks, isdelete))
self._execute_nonrecursive()
def _execute_nonrecursive(self):
while self._nonrecursive_stack:
(action, trans, task, isdelete) =
self._nonrecursive_stack.pop()
if action == 'E': #execute
self._execute(trans, task, isdelete)
elif action == 'D': #dependencies
self.execute_dependencies(trans, task)
else: #action = 'X': delete
self.delete_objects(trans, task)
def _execute(self, trans, tasks, isdelete=None):
if isdelete is not True:
for task in tasks:
self.execute_save_steps(trans, task)
if isdelete is not False:
for task in reversed(tasks):
self.execute_delete_steps(trans, task)
def save_objects(self, trans, task):
task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
def delete_objects(self, trans, task):
task.mapper._delete_obj(task.polymorphic_todelete_objects,
trans)
def execute_dependency(self, trans, dep, isdelete):
dep.execute(trans, isdelete)
def execute_save_steps(self, trans, task):
self.save_objects(trans, task)
for dep in task.polymorphic_cyclical_dependencies:
self.execute_dependency(trans, dep, False)
for dep in task.polymorphic_cyclical_dependencies:
self.execute_dependency(trans, dep, True)
self._nonrecursive_stack.append(('D',trans, task, None))
self.execute_cyclical_dependencies(trans, task, False)
#self.execute_dependencies(trans, task)
def execute_delete_steps(self, trans, task):
self._nonrecursive_stack.append(('X', trans, task, None))
self.execute_cyclical_dependencies(trans, task, True)
#self.delete_objects(trans, task)
def execute_dependencies(self, trans, task):
polymorphic_dependencies = list(task.polymorphic_dependencies)
for dep in polymorphic_dependencies:
self.execute_dependency(trans, dep, False)
for dep in reversed(polymorphic_dependencies):
self.execute_dependency(trans, dep, True)
def execute_cyclical_dependencies(self, trans, task, isdelete):
for t in reversed(task.dependent_tasks):
self._nonrecursive_stack.append(('E',trans, [t],
isdelete))
#self.execute(trans, [t], isdelete)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---