仅由一个功能接收的django信号

时间:2012-04-07 18:02:23

标签: django django-signals

我有一个发送信号的模型:

class WMTransaction(models.Model):
    def save(self, *args, **kwargs):
        if self.status == 'completed':
            self.completed = datetime.datetime.now()
            try:
                old = WMTransaction.objects.get(pk=self.pk)
                if old.status == 'processing':
                    print 'sending signal'
                    payment_done.send(self)
            except:
                pass
        super(WMTransaction, self).save(*args, **kwargs)

我也有2个模块的接收器:

@receiver(payment_done, dispatch_uid="make_this_signal_unique", weak=False)
def subscribe(sender, **kwargs):
    print 'subscribing'
    # processing

@receiver(payment_done, dispatch_uid="this_signal_is_also_unique", weak=False)
def buy(sender, **kwargs):
    print 'buying'
    # processing

问题是调用了订阅功能,并且购买 - 不是......两个模块都在已安装的应用中,这些模块中的其他功能正常工作。信号有什么问题?

1 个答案:

答案 0 :(得分:1)

是否已安装module_B并且buy的定义实际上已执行?在payment_done.receivers行前检查payment_done.send