def handle(self, *args, **options): bleeps = Bleep.objects.filter( bleep_status='qued' ) for bleep in bleeps: # Dispatch the bleep BleepService.dispatch(bleep) self.stdout.write('dispatched bleep %s to %s service\n' % (str(bleep.id), bleep.bleep_service))
def handle(self, *args, **options): bleeps = Bleep.objects.filter(bleep_status='qued') for bleep in bleeps: # Dispatch the bleep BleepService.dispatch(bleep) self.stdout.write('dispatched bleep %s to %s service\n' % (str(bleep.id), bleep.bleep_service))
def send(request, bleep_id): print 'debuggery: dispatching %s to external service' % bleep_id """ Dispatch the bleep """ b = get_object_or_404(Bleep, pk=bleep_id) BleepService.dispatch(b) # return to page return render_to_response('bleep/detail.html', { 'bleep': b}, context_instance=RequestContext(request))
def add(request): """ Add a bleep to the bleepdom """ print 'debuggery: inside add function...' if request.method == 'POST': # merge the GET and POST params reqParams = request.POST.copy() reqParams.update(request.GET) form = BleepForm(reqParams) if form.is_valid(): print 'debuggery: add form is valid' # Initialize the date and status new_instance = form.save(commit=False) new_instance.bleep_status='qued' new_instance.bleep_pub_date = datetime.datetime.now() # Collect the input params new_instance.bleep_get_data = request.META['QUERY_STRING'] if request.raw_post_data: new_instance.bleep_post_data = request.raw_post_data # Save the data to the model new_instance.save() if not settings.NO_AUTO_SEND_MESSAGE: # send it! print 'debuggery: Automatically sending the bleep...' result = BleepService.dispatch(new_instance) else: print 'debuggery: bleep is being held in queue for later processing' # Return to the new bleep page return HttpResponseRedirect('/bleeps/'+str(new_instance.id)) else: logger.debug('the add form was NOT valid') else: return render_to_response('bleep/create.html', { 'form':BleepForm( initial={'bleep_status':'qued', 'bleep_pub_date':datetime.datetime.now()})}, context_instance=RequestContext(request))