示例#1
0
文件: signals.py 项目: xltian/nitrate
class QPIDProcessor(object):
    def __init__(self):
        self.settings = settings.PLUGIN_SETTINGS
        self.sender = QPIDSender(settings.URL, **settings.PLUGIN_SETTINGS)
    
    def __call__(self, data):
        return self.push(data)
    
    def push(self, data):
        content, properties = self.process_data(data)
        if content:
            self.sender.send(content = content, properties = properties)
    
    def process_data(self, data):
        model = data['model']
        instance = data['instance']
        signal = data['signal']
        content = model._meta.module_name.title()
        properties = instance.serialize()
        if signal == signals.create:
            content += ' create'
        elif signal == signals.update:
            content += ' update'
        elif signal == signals.delete:
            content += ' delete'
        else:
            return None, None
        return content, properties
示例#2
0
文件: signals.py 项目: xltian/nitrate
 def __init__(self):
     self.settings = settings.PLUGIN_SETTINGS
     self.sender = QPIDSender(settings.URL, **settings.PLUGIN_SETTINGS)