def dispatch(cls, instance): """ Dispatch the bleep to its receivers """ if 'qued' == instance.bleep_status: try: print 'debuggery: looking up parser for content_type ' + instance.bleep_content_type parser = BleepParser.get_parser(instance.bleep_content_type) print 'debuggery: parser='+parser.get_name() target_svc = BleepService.get_service(instance.bleep_service) print 'debuggery: target_svc='+target_svc.get_name() instance.bleep_status = 'dspd' instance.save() print 'debuggery: telling service to doit...' result = target_svc.doit(instance, parser) instance.bleep_status = 'comp' instance.save() print 'debuggery: adding comment about completion...' instance.add_comment(result.get_msgs(), cat=target_svc.get_name(), stat="completed") print 'debuggery: comment added.' except BleepServiceError as (exc): instance.add_comment("Service request failed. Cause: "+ str(exc)) instance.bleep_status = 'fail' instance.save() else: print 'debuggery: bleep not queued. status: %s' % instance.bleep_status
def dispatch(cls, instance): """ Dispatch the bleep to its receivers """ if 'qued' == instance.bleep_status: try: print 'debuggery: looking up parser for content_type ' + instance.bleep_content_type parser = BleepParser.get_parser(instance.bleep_content_type) print 'debuggery: parser=' + parser.get_name() target_svc = BleepService.get_service(instance.bleep_service) print 'debuggery: target_svc=' + target_svc.get_name() instance.bleep_status = 'dspd' instance.save() print 'debuggery: telling service to doit...' result = target_svc.doit(instance, parser) instance.bleep_status = 'comp' instance.save() print 'debuggery: adding comment about completion...' instance.add_comment(result.get_msgs(), cat=target_svc.get_name(), stat="completed") print 'debuggery: comment added.' except BleepServiceError as (exc): instance.add_comment("Service request failed. Cause: " + str(exc)) instance.bleep_status = 'fail' instance.save() else: print 'debuggery: bleep not queued. status: %s' % instance.bleep_status