Ticket #10753: dj.patch

File dj.patch, 1.2 KB (added by Karataev Pavel, 11 years ago)
  • django/dispatch/dispatcher.py

     
    120120        else:
    121121            lookup_key = (_make_id(receiver), _make_id(sender))
    122122       
    123         for index in xrange(len(self.receivers)):
    124             (r_key, _) = self.receivers[index]
    125             if r_key == lookup_key:
    126                 del self.receivers[index]
     123        self.receivers = filter(lambda value: value[0] != lookup_key, self.receivers)
    127124
    128125    def send(self, sender, **named):
    129126        """Send signal from sender to all connected receivers.
     
    205202    def _remove_receiver(self, receiver):
    206203        """Remove dead receivers from connections."""
    207204
    208         to_remove = []
    209         for key, connected_receiver in self.receivers:
    210             if connected_receiver == receiver:
    211                 to_remove.append(key)
    212         for key in to_remove:
    213             for idx, (r_key, _) in enumerate(self.receivers):
    214                 if r_key == key:
    215                     del self.receivers[idx]
     205        self.receivers = filter(lambda value: value[1] != receiver, self.receivers)
Back to Top