unitofwork.GetDependentObjects(uow, self, False, True)
unitofwork.GetDependentObjects(uow, self, True, True)
+
+
+ def _has_flush_activity(self, uow):
+ if self.post_update and self._check_reverse(uow):
+ return
after_save = unitofwork.ProcessAll(uow, self, False, True)
before_delete = unitofwork.ProcessAll(uow, self, True, True)
child_deletes,
after_save,
before_delete)
+
def per_state_flush_actions(self, uow, states, isdelete):
"""establish actions and dependencies related to a flush.
"""
+ # TODO: this check sucks. somehow get mapper to
+ # not even call this.
+ if ('has_flush_activity', self) not in uow.attributes:
+ return
+
+ # TODO: why are we calling this ? shouldnt per_property
+ # have stopped us from getting keyhere ?
if self.post_update and self._check_reverse(uow):
# TODO: coverage here
- return iter([])
+ return
# locate and disable the aggregate processors
# for this dependency
- before_delete = unitofwork.ProcessAll(uow, self, True, True)
- before_delete.disabled = True
- after_save = unitofwork.ProcessAll(uow, self, False, True)
- after_save.disabled = True
+ if isdelete:
+ before_delete = unitofwork.ProcessAll(uow, self, True, True)
+ before_delete.disabled = True
+ else:
+ after_save = unitofwork.ProcessAll(uow, self, False, True)
+ after_save.disabled = True
# check if the "child" side is part of the cycle
after_save, before_delete,
isdelete, childisdelete)
- # ... but at the moment it
- # does so we emit a null iterator
- return iter([])
def presort_deletes(self, uowcommit, states):
- pass
+ return False
def presort_saves(self, uowcommit, states):
- pass
+ return False
def process_deletes(self, uowcommit, states):
pass
def process_saves(self, uowcommit, states):
pass
+ def _prop_has_changes(self, uowcommit, states):
+ for s in states:
+ # TODO: add a high speed method
+ # to InstanceState which returns: attribute
+ # has a non-None value, or had one
+ history = uowcommit.get_attribute_history(
+ s,
+ self.key,
+ passive=True)
+ if history and not history.empty():
+ return True
+ else:
+ return False
+
def _verify_canload(self, state):
if state is not None and \
not self.mapper._canload(state, allow_subtypes=not self.enable_typechecks):
"""
for p in self.prop._reverse_property:
- if not p.viewonly and p._dependency_processor and \
- (unitofwork.ProcessAll,
- p._dependency_processor, False, True) in \
- uow.postsort_actions:
- return True
+ if not p.viewonly and p._dependency_processor:
+ return p.key < self.key
else:
return False
# foreign key to the parent set to NULL
should_null_fks = not self.cascade.delete and \
not self.passive_deletes == 'all'
+
for state in states:
history = uowcommit.get_attribute_history(
state,
for child in history.unchanged:
if child is not None:
uowcommit.register_object(child)
-
+
+
def presort_saves(self, uowcommit, states):
for state in states:
history = uowcommit.get_attribute_history(
child,
False,
self.passive_updates)
-
+
def process_deletes(self, uowcommit, states):
# head object is being deleted, and we manage its list of
# child objects the child objects have to have their foreign
'delete', child):
uowcommit.register_object(
attributes.instance_state(c), isdelete=True)
-
+
def presort_saves(self, uowcommit, states):
for state in states:
uowcommit.register_object(state)
self.key,
passive=self.passive_deletes)
if history:
+ ret = True
for child in history.deleted:
if self.hasparent(child) is False:
uowcommit.register_object(child, isdelete=True)
# so that mapper save_obj() gets a hold of changes
unitofwork.GetDependentObjects(uow, self, False, False)
else:
+
+ ##### TODO ########
+ # Get this out of here if self.parent.base_mapper isn't in the flush!!!!
+
# for passive updates, register objects in the process stage
# so that we avoid ManyToOneDP's registering the object without
# the listonly flag in its own preprocess stage (results in UPDATE)
(parent_saves, after_save)
])
+ def _has_flush_activity(self, uow):
+ pass
+
def per_state_flush_actions(self, uow, states, isdelete):
- # TODO: coverage here
- return iter([])
+ pass
def presort_deletes(self, uowcommit, states):
assert False
unitofwork.GetDependentObjects(uow, self, False, True)
else:
DependencyProcessor.per_property_flush_actions(self, uow)
+
+ def _has_flush_activity(self, uow):
+ if self._check_reverse(uow):
+ return
+ else:
+ DependencyProcessor._has_flush_activity(self, uow)
def per_state_flush_actions(self, uow, states, isdelete):
if self._check_reverse(uow):
- return iter([])
+ return
else:
- return DependencyProcessor.\
+ DependencyProcessor.\
per_state_flush_actions(self, uow, states, isdelete)
def per_property_dependencies(self, uow, parent_saves,
])
def presort_deletes(self, uowcommit, states):
- pass
-
+ if not self.passive_deletes:
+ for state in states:
+ history = uowcommit.get_attribute_history(
+ state,
+ self.key,
+ passive=self.passive_deletes)
+
def presort_saves(self, uowcommit, states):
+ for state in states:
+ history = uowcommit.get_attribute_history(
+ state,
+ self.key,
+ False)
+
if not self.cascade.delete_orphan:
return
child):
uowcommit.register_object(
attributes.instance_state(c), isdelete=True)
-
+
def process_deletes(self, uowcommit, states):
secondary_delete = []
secondary_insert = []
]
).difference(cycles)
- #sort = topological.sort(self.dependencies, postsort_actions)
+ sort = topological.sort(self.dependencies, postsort_actions)
#print "--------------"
#print self.dependencies
- #print postsort_actions
+ print postsort_actions
+ print "COUNT OF POSTSORT ACTIONS", len(postsort_actions)
# execute
if cycles:
self.processed = set()
def execute(self, uow):
+
states = list(self._elements(uow))
if states:
if self.delete:
else:
self.dependency_processor.presort_saves(uow, states)
self.processed.update(states)
+
+ if ('has_flush_activity', self.dependency_processor) not in uow.attributes:
+ # TODO: wont be calling self.fromparent here once detectkeyswitch works
+ if not self.fromparent or self.dependency_processor._prop_has_changes(uow, states):
+ self.dependency_processor._has_flush_activity(uow)
+ uow.attributes[('has_flush_activity', self.dependency_processor)] = True
+
return True
else:
return False
self.dependency_processor.process_saves(uow, states)
def per_state_flush_actions(self, uow):
+ # we let the mappers call this,
+ # so that a ProcessAll which is between two mappers that
+ # are part of a cycle (but the ProcessAll itself is not
+ # in the cycle), also becomes a per-state processor,
+ # and a dependency between the two states as well
return iter([])
class SaveUpdateAll(PostSortRec):