Ticket #5422: save-send-raw-flag_v2.diff
File save-send-raw-flag_v2.diff, 1.8 KB (added by , 17 years ago) |
---|
-
django/db/models/base.py
207 207 _prepare = classmethod(_prepare) 208 208 209 209 def save(self, raw=False): 210 dispatcher.send(signal=signals.pre_save, sender=self.__class__, instance=self )210 dispatcher.send(signal=signals.pre_save, sender=self.__class__, instance=self, raw=raw) 211 211 212 212 non_pks = [f for f in self._meta.fields if not f.primary_key] 213 213 cursor = connection.cursor() … … 268 268 269 269 # Run any post-save hooks. 270 270 dispatcher.send(signal=signals.post_save, sender=self.__class__, 271 instance=self, created=(not record_exists) )271 instance=self, created=(not record_exists), raw=raw) 272 272 273 273 save.alters_data = True 274 274 -
tests/modeltests/signals/models.py
15 15 16 16 def pre_save_test(sender, instance, **kwargs): 17 17 print 'pre_save signal,', instance 18 if kwargs['raw']: 19 print 'Is raw' 18 20 19 21 def post_save_test(sender, instance, **kwargs): 20 22 print 'post_save signal,', instance … … 23 25 print 'Is created' 24 26 else: 25 27 print 'Is updated' 28 if kwargs['raw']: 29 print 'Is raw' 26 30 27 31 def pre_delete_test(sender, instance, **kwargs): 28 32 print 'pre_delete signal,', instance … … 50 54 post_save signal, Tom Smith 51 55 Is updated 52 56 57 >>> p1.save(raw=True) 58 pre_save signal, Tom Smith 59 Is raw 60 post_save signal, Tom Smith 61 Is updated 62 Is raw 63 53 64 >>> p1.delete() 54 65 pre_delete signal, Tom Smith 55 66 instance.id is not None: True