Esempio n. 1
0
    def enqueue(self, signal, sender=None, **kwargs):
        """ Serialize the parameters of a signal call, encode
            the serialized structure, and push the encoded
            string onto the queue. """

        if signal.regkey is not None:
            if self.ping():
                queue_json = {
                    'signal': {
                        signal.regkey: signal.name
                    },
                    #'sender': None,
                    'enqueue_runmode': self.runmode
                }

                if sender is not None:
                    queue_json.update({
                        'sender':
                        dict(app_label=sender._meta.app_label,
                             modl_name=sender._meta.object_name.lower())
                    })

                for k, v in kwargs.items():
                    queue_json.update({
                        k: signal.mapping.demap(v),
                    })

                #print queue_json
                self.push(json.dumps(queue_json))
                return queue_json
        else:
            raise signalqueue.SignalRegistryError(
                "Signal has no regkey value.")
Esempio n. 2
0
 def enqueue(self, signal, sender=None, **kwargs):
     """
     Serialize the parameters of a signal call, encode the serialized structure,
     and push the encoded string onto the queue.
     
     """
     if signal.regkey is not None:
         if self.ping():
             queue_json = {
                 'signal': { signal.regkey: signal.name },
                 'enqueue_runmode': self.runmode,
                 #'sender': None,
             }
             if sender is not None:
                 queue_json.update({
                     'sender': dict(app_label=sender._meta.app_label, modl_name=sender._meta.object_name.lower()),
                 })
             
             for k, v in kwargs.items():
                 if k in signal.mapping:
                     queue_json.update({ k: signal.mapping[k]().map(v), })
             
             self.push(json.dumps(queue_json))
             return queue_json
     else:
         raise signalqueue.SignalRegistryError("Signal has no regkey value.")
Esempio n. 3
0
 def _set_struct(self, newstruct):
     if self.keys.issuperset(newstruct.keys()):
         from signalqueue.utils import json
         self.value = json.dumps(newstruct)
Esempio n. 4
0
 def _set_struct(self, newstruct):
     if self.keys.issuperset(newstruct.keys()):
         from signalqueue.utils import json
         self.value = json.dumps(newstruct)