Ticket #2154: insert_update_signals.diff
File insert_update_signals.diff, 1.5 KB (added by , 18 years ago) |
---|
-
db/models/base.py
161 161 (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), [pk_val]) 162 162 # If it does already exist, do an UPDATE. 163 163 if cursor.fetchone(): 164 dispatcher.send(signal=signals.save_update, sender=self.__class__, instance=self) 164 165 db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks] 165 166 cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \ 166 167 (backend.quote_name(self._meta.db_table), … … 170 171 else: 171 172 record_exists = False 172 173 if not pk_set or not record_exists: 174 dispatcher.send(signal=signals.save_insert, sender=self.__class__, instance=self) 173 175 field_names = [backend.quote_name(f.column) for f in self._meta.fields if not isinstance(f, AutoField)] 174 176 db_values = [f.get_db_prep_save(f.pre_save(self, True)) for f in self._meta.fields if not isinstance(f, AutoField)] 175 177 # If the PK has been manually set, respect that. -
db/models/signals.py
4 4 post_init = object() 5 5 6 6 pre_save = object() 7 save_update = object() 8 save_insert = object() 7 9 post_save = object() 8 10 9 11 pre_delete = object()