@@ 1,6 1,7 @@
from django.db import models
from models import CallbackMap
from base import CallbackException, CallbackBase
+from signals import stored_callback, processed_callback
REQUIRED_METHODS = ('process',)
@@ 46,7 47,13 @@ class CallbackManager(object):
model_instance.save()
cls = self.get_callback_class(model_instance)
- return CallbackMap.objects.store_callback(model_instance)
+ callback_instance = CallbackMap.objects.store_callback(model_instance)
+ stored_callback.send(
+ sender=self,
+ callback_instance=callback_instance,
+ model_instance=model_instance,
+ )
+ return callback_instance
def process_callback(self, callback_instance):
model = callback_instance.content_object
@@ 54,6 61,11 @@ class CallbackManager(object):
try:
cls.process(model)
callback_instance.mark_complete()
+ processed_callback.send(
+ sender=self,
+ callback_instance=callback_instance,
+ model_instance=model,
+ )
except Exception, e:
callback_instance.mark_error(str(e))
raise CallbackException(str(e))
@@ 0,0 1,10 @@
+from django import dispatch
+
+
+stored_callback = dispatch.Signal(
+ providing_args=['callback_instance', 'model_instance'],
+)
+
+processed_callback = dispatch.Signal(
+ providing_args=['callback_instance', 'model_instance'],
+)