I'm working with Django signals, but they seem to be received twice, even if emitted once. Here's the code I'm working with (it's a simple wrapper to use Uploadify with Django)...
# Signal-emitting code... emits whenever a file upload is received
# ----------------------------------------------------------------
upload_recieved = django.dispatch.Signal(providing_args=['data'])
def upload(request, *args, **kwargs):
if request.method == 'POST':
if request.FILES:
print 'sending signal'
upload_recieved.send(sender='uploadify', data=request.FILES['Filedata'])
return HttpResponse('True')
# Signal-receiving code...
# ----------------------------------------------------------------
def upload_received_handler(sender, data, **kwargs):
print 'upload received handler'
print 'connecting signal'
upload_recieved.connect(upload_received_handler)
(I just noticed my signal is spelled wrong)
I'm sure you noticed the print statements in there. On the console, this is what it's showing:
(server starts)
connecting signal
...
sending signal
upload received handler
upload received handler # << == where is this 2nd one coming from?
127.0.0.1 - - [25/Sep/2009 07:28:22] "POST /uploadify/upload/ HTTP/1.1" 200 -
(also odd is why does Django report the page POST after the signals are fired?)