def before_flush(self, obj=None): if obj is None: self.objects_added = list(self.session.uow.new) self.objects_modified = list(self.session.uow.dirty) self.objects_deleted = list(self.session.uow.deleted) else: # pragma no cover st = state(obj) if st.status == st.new: self.objects_added = [ obj ] elif st.status == st.dirty: self.objects_modified = [ obj ] elif st.status == st.deleted: self.objects_deleted = [ obj ]
def before_flush(self, obj=None): if obj is None: self.objects_added = list(self.session.uow.new) self.objects_modified = list(self.session.uow.dirty) self.objects_deleted = list(self.session.uow.deleted) else: # pragma no cover st = state(obj) if st.status == st.new: self.objects_added = [obj] elif st.status == st.dirty: self.objects_modified = [obj] elif st.status == st.deleted: self.objects_deleted = [obj]
def before_flush(self, obj=None): """Before the session is flushed for ``obj`` If ``obj`` is ``None`` it means all the objects in the UnitOfWork which can be retrieved by iterating over ``ODMSession.uow`` """ if obj is not None: # this was an explicit flush() call, so let it go through return for o in self.session.uow: if not getattr(o, 'explicit_flush', False): state(o).status = ObjectState.clean
def _needs_update(o): old = dict(state(o).original_document) new = dict(state(o).document) return o.should_update_index(old, new)