Ticket #6108: pre_delete.patch

File pre_delete.patch, 1.8 KB (added by Gábor Farkas <gabor@…>, 17 years ago)
  • django/db/models/query.py

     
    11321132
    11331133        # Pre notify all instances to be deleted
    11341134        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)
    11361136
    11371137        pk_list = [pk for pk,instance in seen_objs[cls]]
    11381138        for related in cls._meta.get_all_related_many_to_many_objects():
  • tests/modeltests/signals/models.py

     
    2424        else:
    2525            print 'Is updated'
    2626
    27 def pre_delete_test(sender, instance, **kwargs):
     27def pre_delete_test(sender, instance, all_objs, **kwargs):
    2828    print 'pre_delete signal,', instance
    2929    print 'instance.id is not None: %s' % (instance.id != None) 
     30    print 'all objects to be deleted: %s' % all_objs
    3031
    3132def post_delete_test(sender, instance, **kwargs):
    3233    print 'post_delete signal,', instance
     
    5354>>> p1.delete()
    5455pre_delete signal, Tom Smith
    5556instance.id is not None: True
     57all objects to be deleted: {<class 'modeltests.signals.models.Person'>: [(1L, <Person: Tom Smith>)]}
    5658post_delete signal, Tom Smith
    5759instance.id is None: False
    5860
     
    7274>>> p2.delete()
    7375pre_delete signal, James Jones
    7476instance.id is not None: True
     77all objects to be deleted: {<class 'modeltests.signals.models.Person'>: [(99998, <Person: James Jones>)]}
    7578post_delete signal, James Jones
    7679instance.id is None: False
    7780
Back to Top