src/reversion/revisions.py
def register(self, model=None, adapter_cls=VersionAdapter, signals=None, eager_signals=None, follow_parents=True,
                 **field_overrides):
        """Registers a model with this revision manager."""
        # Default to post_save and post_delete if no signals are given
        if signals is None and eager_signals is None:
            signals = [post_save, pre_delete]
            eager_signals = [pre_delete]
        # Store signals for usage in the signal receiver
        self._eager_signals[model] = list(eager_signals or [])
        self._signals[model] = list(signals or [])
        # Return a class decorator if model is not given

        if follow_parents:
            field_overrides['follow'] = follow = field_overrides.get('follow', [])

            for parent_model, field in model._meta.parents.items():
                if field:
                    follow.append(field.name)
                if not self.is_registered(parent_model):
                    self.register(parent_model, adapter_cls, signals, eager_signals, follow_parents)

        if model is None:
            return partial(self.register, adapter_cls=adapter_cls, **field_overrides)
        # Prevent multiple registration.
        if self.is_registered(model):
            raise RegistrationError('{model} has already been registered with django-reversion'.format(
                model = model,
            ))
        # Perform any customization.
        if field_overrides:
            adapter_cls = type(adapter_cls.__name__, (adapter_cls,), field_overrides)
        # Perform the registration.
        adapter_obj = adapter_cls(model)
        self._registered_models[self._registration_key_for_model(model)] = adapter_obj
        # Connect to the selected signals of the model.
        all_signals = self._signals[model] + self._eager_signals[model]
        for signal in all_signals:
            signal.connect(self._signal_receiver, model)

        model.reversion_versions = GenericRelation(Version)
        model.reversion_versions.contribute_to_class(model, 'reversion_versions')

        return model
Registers a model with this revision manager.
Registers a model with this revision manager.
Registers a model with this revision manager .
def register(self, model=None, adapter_cls=VersionAdapter, signals=None, eager_signals=None, follow_parents=True,
                 **field_overrides):
        if signals is None and eager_signals is None:
            signals = [post_save, pre_delete]
            eager_signals = [pre_delete]
        self._eager_signals[model] = list(eager_signals or [])
        self._signals[model] = list(signals or [])
        if follow_parents:
            field_overrides['follow'] = follow = field_overrides.get('follow', [])
            for parent_model, field in model._meta.parents.items():
                if field:
                    follow.append(field.name)
                if not self.is_registered(parent_model):
                    self.register(parent_model, adapter_cls, signals, eager_signals, follow_parents)
        if model is None:
            return partial(self.register, adapter_cls=adapter_cls, **field_overrides)
        if self.is_registered(model):
            raise RegistrationError('{model} has already been registered with django-reversion'.format(
                model = model,
            ))
        if field_overrides:
            adapter_cls = type(adapter_cls.__name__, (adapter_cls,), field_overrides)
        adapter_obj = adapter_cls(model)
        self._registered_models[self._registration_key_for_model(model)] = adapter_obj
        all_signals = self._signals[model] + self._eager_signals[model]
        for signal in all_signals:
            signal.connect(self._signal_receiver, model)
        model.reversion_versions = GenericRelation(Version)
        model.reversion_versions.contribute_to_class(model, 'reversion_versions')
        return model
def register ( self , model = None , adapter_cls = VersionAdapter , signals = None , eager_signals = None , follow_parents = True , ** field_overrides ) : if signals is None and eager_signals is None : signals = [ post_save , pre_delete ] eager_signals = [ pre_delete ] self . _eager_signals [ model ] = list ( eager_signals or [ ] ) self . _signals [ model ] = list ( signals or [ ] ) if follow_parents : field_overrides [ 'follow' ] = follow = field_overrides . get ( 'follow' , [ ] ) for parent_model , field in model . _meta . parents . items ( ) : if field : follow . append ( field . name ) if not self . is_registered ( parent_model ) : self . register ( parent_model , adapter_cls , signals , eager_signals , follow_parents ) if model is None : return partial ( self . register , adapter_cls = adapter_cls , ** field_overrides ) if self . is_registered ( model ) : raise RegistrationError ( '{model} has already been registered with django-reversion' . format ( model = model , ) ) if field_overrides : adapter_cls = type ( adapter_cls . __name__ , ( adapter_cls , ) , field_overrides ) adapter_obj = adapter_cls ( model ) self . _registered_models [ self . _registration_key_for_model ( model ) ] = adapter_obj all_signals = self . _signals [ model ] + self . _eager_signals [ model ] for signal in all_signals : signal . connect ( self . _signal_receiver , model ) model . reversion_versions = GenericRelation ( Version ) model . reversion_versions . contribute_to_class ( model , 'reversion_versions' ) return model
Registers a model with this revision manager.
Registers a model with this revision manager .
"""Registers a model with this revision manager.""" # Default to post_save and post_delete if no signals are given # Store signals for usage in the signal receiver # Return a class decorator if model is not given # Prevent multiple registration. # Perform any customization. # Perform the registration. # Connect to the selected signals of the model.
self
model
adapter_cls
signals
eager_signals
follow_parents