src/reversion/revisions.py
def _signal_receiver(self, instance, signal, **kwargs):
        """Adds registered models to the current revision, if any."""
        if self._revision_context_manager.is_active() and not self._revision_context_manager.is_managing_manually():
            eager = signal in self._eager_signals[instance.__class__]
            adapter = self.get_adapter(instance.__class__)

            if signal in [pre_delete, post_delete]:
                type = Version.TYPE.DELETED
            elif signal == post_save:
                type = Version.TYPE.CREATED if kwargs.get('created') else Version.TYPE.CHANGED
            elif signal == pre_save:
                type = Version.TYPE.CREATED if instance.pk is None else Version.TYPE.CHANGED

            if eager:
                # pre_delete is a special case, because the instance will
                # be modified by django right after this.
                # don't use a lambda, but get the data out now.
                version_data = adapter.get_version_data(instance, self._revision_context_manager._db)
                self._revision_context_manager.add_to_context(self, type, copy.copy(instance), version_data)
                for obj, follower_type in self._follow_relationships([(instance, type)]):
                    adapter = self.get_adapter(obj.__class__)
                    version_data = adapter.get_version_data(obj, self._revision_context_manager._db)
                    self._revision_context_manager.add_to_context(self, follower_type, copy.copy(obj), version_data)
            else:
                version_data = lambda: adapter.get_version_data(instance, self._revision_context_manager._db)
                self._revision_context_manager.add_to_context(self, type, instance, version_data)
Adds registered models to the current revision, if any.
Adds registered models to the current revision, if any.
Adds registered models to the current revision if any .
def _signal_receiver(self, instance, signal, **kwargs):
        if self._revision_context_manager.is_active() and not self._revision_context_manager.is_managing_manually():
            eager = signal in self._eager_signals[instance.__class__]
            adapter = self.get_adapter(instance.__class__)
            if signal in [pre_delete, post_delete]:
                type = Version.TYPE.DELETED
            elif signal == post_save:
                type = Version.TYPE.CREATED if kwargs.get('created') else Version.TYPE.CHANGED
            elif signal == pre_save:
                type = Version.TYPE.CREATED if instance.pk is None else Version.TYPE.CHANGED
            if eager:
                version_data = adapter.get_version_data(instance, self._revision_context_manager._db)
                self._revision_context_manager.add_to_context(self, type, copy.copy(instance), version_data)
                for obj, follower_type in self._follow_relationships([(instance, type)]):
                    adapter = self.get_adapter(obj.__class__)
                    version_data = adapter.get_version_data(obj, self._revision_context_manager._db)
                    self._revision_context_manager.add_to_context(self, follower_type, copy.copy(obj), version_data)
            else:
                version_data = lambda: adapter.get_version_data(instance, self._revision_context_manager._db)
                self._revision_context_manager.add_to_context(self, type, instance, version_data)
def _signal_receiver ( self , instance , signal , ** kwargs ) : if self . _revision_context_manager . is_active ( ) and not self . _revision_context_manager . is_managing_manually ( ) : eager = signal in self . _eager_signals [ instance . __class__ ] adapter = self . get_adapter ( instance . __class__ ) if signal in [ pre_delete , post_delete ] : type = Version . TYPE . DELETED elif signal == post_save : type = Version . TYPE . CREATED if kwargs . get ( 'created' ) else Version . TYPE . CHANGED elif signal == pre_save : type = Version . TYPE . CREATED if instance . pk is None else Version . TYPE . CHANGED if eager : version_data = adapter . get_version_data ( instance , self . _revision_context_manager . _db ) self . _revision_context_manager . add_to_context ( self , type , copy . copy ( instance ) , version_data ) for obj , follower_type in self . _follow_relationships ( [ ( instance , type ) ] ) : adapter = self . get_adapter ( obj . __class__ ) version_data = adapter . get_version_data ( obj , self . _revision_context_manager . _db ) self . _revision_context_manager . add_to_context ( self , follower_type , copy . copy ( obj ) , version_data ) else : version_data = lambda : adapter . get_version_data ( instance , self . _revision_context_manager . _db ) self . _revision_context_manager . add_to_context ( self , type , instance , version_data )
Adds registered models to the current revision, if any.
Adds registered models to the current revision if any .
"""Adds registered models to the current revision, if any.""" # pre_delete is a special case, because the instance will # be modified by django right after this. # don't use a lambda, but get the data out now.
self
instance
signal