Ticket #2154: insert_update_signals.diff

File insert_update_signals.diff, 1.5 KB (added by Matias Hermanrud Fjeld <mhf@…>, 18 years ago)
  • db/models/base.py

     
    161161                (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), [pk_val])
    162162            # If it does already exist, do an UPDATE.
    163163            if cursor.fetchone():
     164                dispatcher.send(signal=signals.save_update, sender=self.__class__, instance=self)
    164165                db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks]
    165166                cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \
    166167                    (backend.quote_name(self._meta.db_table),
     
    170171            else:
    171172                record_exists = False
    172173        if not pk_set or not record_exists:
     174            dispatcher.send(signal=signals.save_insert, sender=self.__class__, instance=self)
    173175            field_names = [backend.quote_name(f.column) for f in self._meta.fields if not isinstance(f, AutoField)]
    174176            db_values = [f.get_db_prep_save(f.pre_save(self, True)) for f in self._meta.fields if not isinstance(f, AutoField)]
    175177            # If the PK has been manually set, respect that.
  • 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