1. Peter Sanchez
  2. django-callback

Commits

Peter Sanchez  committed e12e119

Added signals for stored and processed callbacks

  • Participants
  • Parent commits be25126
  • Branches default

Comments (0)

Files changed (2)

File callback/callback.py

View file
 from django.db import models
 from models import CallbackMap
 from base import CallbackException, CallbackBase
+from signals import stored_callback, processed_callback
 
 REQUIRED_METHODS = ('process',)
 
             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
         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))

File callback/signals.py

View file
+from django import dispatch
+
+
+stored_callback = dispatch.Signal(
+    providing_args=['callback_instance', 'model_instance'],
+)
+
+processed_callback = dispatch.Signal(
+    providing_args=['callback_instance', 'model_instance'],
+)