Ticket #6108: pre_delete.patch
File pre_delete.patch, 1.8 KB (added by , 17 years ago) |
---|
-
django/db/models/query.py
1132 1132 1133 1133 # Pre notify all instances to be deleted 1134 1134 for pk_val, instance in seen_objs[cls]: 1135 dispatcher.send(signal=signals.pre_delete, sender=cls, instance=instance )1135 dispatcher.send(signal=signals.pre_delete, sender=cls, instance=instance, all_objs = seen_objs) 1136 1136 1137 1137 pk_list = [pk for pk,instance in seen_objs[cls]] 1138 1138 for related in cls._meta.get_all_related_many_to_many_objects(): -
tests/modeltests/signals/models.py
24 24 else: 25 25 print 'Is updated' 26 26 27 def pre_delete_test(sender, instance, **kwargs):27 def pre_delete_test(sender, instance, all_objs, **kwargs): 28 28 print 'pre_delete signal,', instance 29 29 print 'instance.id is not None: %s' % (instance.id != None) 30 print 'all objects to be deleted: %s' % all_objs 30 31 31 32 def post_delete_test(sender, instance, **kwargs): 32 33 print 'post_delete signal,', instance … … 53 54 >>> p1.delete() 54 55 pre_delete signal, Tom Smith 55 56 instance.id is not None: True 57 all objects to be deleted: {<class 'modeltests.signals.models.Person'>: [(1L, <Person: Tom Smith>)]} 56 58 post_delete signal, Tom Smith 57 59 instance.id is None: False 58 60 … … 72 74 >>> p2.delete() 73 75 pre_delete signal, James Jones 74 76 instance.id is not None: True 77 all objects to be deleted: {<class 'modeltests.signals.models.Person'>: [(99998, <Person: James Jones>)]} 75 78 post_delete signal, James Jones 76 79 instance.id is None: False 77 80