def _check_object_deleted(self, obj): hist = self.get_depot_history(obj) if state(obj).status == ObjectState.deleted: for prop in mapper(obj).properties: if isinstance(prop, UploadedFileProperty): current_value = prop.__get__(obj, obj.__class__) hist.delete(current_value) self._flush_object(obj)
def get_depot_history(cls, instance): istate = state(instance) if not hasattr(istate, '_depot_history'): istate._depot_history = _DepotHistory() return istate._depot_history