Ticket #2154: insert_update_signals2.diff

File insert_update_signals2.diff, 1.4 KB (added by mhf@…, 18 years ago)

Signals are sent after insert/update

  • db/models/base.py

     
    167167                    ','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]),
    168168                    backend.quote_name(self._meta.pk.attname)),
    169169                    db_values + [pk_val])
     170                dispatcher.send(signal=signals.save_update,
     171                                sender=self.__class__, instance=self)
    170172            else:
    171173                record_exists = False
    172174        if not pk_set or not record_exists:
     
    195197                     backend.get_pk_default_value()))
    196198            if self._meta.has_auto_field and not pk_set:
    197199                setattr(self, self._meta.pk.attname, backend.get_last_insert_id(cursor, self._meta.db_table, self._meta.pk.column))
     200            dispatcher.send(signal=signals.save_insert, sender=self.__class__,
     201                            instance=self)
    198202        transaction.commit_unless_managed()
    199203
    200204        # Run any post-save hooks.
  • db/models/signals.py

     
    44post_init = object()
    55
    66pre_save = object()
     7save_update = object()
     8save_insert = object()
    79post_save = object()
    810
    911pre_delete = object()
Back to Top