mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-14 20:57:19 -04:00
This commit is contained in:
@@ -658,17 +658,17 @@ class PropertyLoader(MapperProperty):
|
||||
#uowcommit.register_task(self.mapper, True, self, self.parent, False)
|
||||
else:
|
||||
raise " no foreign key ?"
|
||||
|
||||
|
||||
def get_object_dependencies(self, obj, uowcommit, passive = True):
|
||||
"""function to retreive the child list off of an object. "passive" means, if its
|
||||
a lazy loaded list that is not loaded yet, dont load it."""
|
||||
if self.uselist:
|
||||
return uowcommit.uow.attributes.get_list_history(obj, self.key, passive = passive)
|
||||
else:
|
||||
return uowcommit.uow.attributes.get_history(obj, self.key)
|
||||
|
||||
def process_dependencies(self, deplist, uowcommit, delete = False):
|
||||
print self.mapper.table.name + " " + repr(deplist.map.values()) + " process_dep isdelete " + repr(delete)
|
||||
|
||||
# function to retreive the child list off of an object. "passive" means, if its
|
||||
# a lazy loaded list that is not loaded yet, dont load it.
|
||||
def getlist(obj, passive = True):
|
||||
if self.uselist:
|
||||
return uowcommit.uow.attributes.get_list_history(obj, self.key, passive = passive)
|
||||
else:
|
||||
return uowcommit.uow.attributes.get_history(obj, self.key)
|
||||
|
||||
# fucntion to set properties across a parent/child object plus an "association row",
|
||||
# based on a join condition
|
||||
@@ -676,6 +676,9 @@ class PropertyLoader(MapperProperty):
|
||||
self._sync_foreign_keys(binary, obj, child, associationrow, clearkeys)
|
||||
setter = BinaryVisitor(sync_foreign_keys)
|
||||
|
||||
def getlist(obj, passive=True):
|
||||
return self.get_object_dependencies(obj, uowcommit, passive)
|
||||
|
||||
associationrow = {}
|
||||
|
||||
# plugin point
|
||||
|
||||
@@ -426,6 +426,26 @@ class UOWTask(object):
|
||||
processor.process_dependencies(targettask.objects, trans, delete = self.isdelete)
|
||||
if not self.listonly and self.isdelete:
|
||||
self.mapper.delete_obj(obj_list, trans)
|
||||
|
||||
def sort_circular_dependencies(self):
|
||||
d = {}
|
||||
head = None
|
||||
for obj in obj_list:
|
||||
d[obj] = UOWTask(self.mapper, self.isdelete, self.listonly)
|
||||
d[obj].dependencies = self.dependencies
|
||||
if head is None:
|
||||
head = obj
|
||||
for dep in self.dependencies:
|
||||
(processor, targettask) = dep
|
||||
if targetttask is self:
|
||||
for o in processor.get_object_dependencies(obj, self, passive = True):
|
||||
if o is head:
|
||||
head = obj
|
||||
d[obj].objects.append(o)
|
||||
if head is None:
|
||||
return self
|
||||
else:
|
||||
return d[head]
|
||||
|
||||
def __str__(self):
|
||||
if self.isdelete:
|
||||
|
||||
Reference in New Issue
Block a user