我有發送模型信號: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