我有发送模型信号:django的信号
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
的问题是订阅函数被调用,而购买 - 不是...两个模块都在安装的应用程序中,这些模块的其他功能正常工作。信号有什么问题?
这两个信号处理程序在'models.py'或导入到'models.py'? – 2012-04-07 18:29:00
**订阅**是在module_A.models和** buy **是在module_B.models – 2012-04-07 18:40:39
非常不可能,但尝试添加一些日志信息到except块,如果没有抛出一些异常 – yedpodtrzitko 2012-04-07 19:09:28