def process_data(sender, **kwargs): data = kwargs.pop('data') context = kwargs.pop('context') source = Source.get(context) logger.debug('Received post_data_save signal from %s context %s' % (sender, context)) triggers = TriggerCache.filter(Source.encode(source)) if triggers: logger.debug('Found %d triggers.' % len(triggers)) if callable(data): data = data() for t in triggers: TriggerThread(t, data, context).start()
def process_error(sender, **kwargs): context = kwargs.pop('context') source = Source.get(context) logger.debug('Received error_signal from %s with context %s' % (sender, context)) handlers = ErrorHandlerCache.filter(Source.encode(source)) logger.debug('Found %d handlers.' % len(handlers)) event = Event(severity=ERROR_SEVERITY, context=context, trigger_result=None) event.save() logger.debug('New Event created: %s' % event) for h in handlers: DestinationThread(h.destination, event, is_error=True).start() system_settings = SystemSettings.get_system_settings() if system_settings.global_error_handler: if not handlers or any([h.allow_global for h in handlers]): for d in GlobalErrorHandlerCache.data(): DestinationThread(d, event, is_error=True).start()