Esempio n. 1
0
 def _validate_encoding(self):
     self.body = data.str2unicode(self.body)
     self.from_addy = data.str2unicode(self.from_addy)
     self.reply_to_addy = data.str2unicode(self.reply_to_addy)
     self.server = data.str2unicode(self.server)
     self.subject = data.str2unicode(self.subject)
     self.to_addy = data.str2unicode(self.to_addy)
Esempio n. 2
0
    def decode(self, data):
        """
        Decode the session using the specified transport (cPickle by
        default).

        @param data: Session data to be decoded
        @type data: str
        @return: Dict
        """
        
        # Detect already decoded data
        if data is None:
            return None # TODO: Is this the right thing to do?
        elif isinstance(data, dict):
            return data

        # Decode using the desired transport
        data = str2unicode(data)
        if self._transport == CPICKLE:
            return cPickle.loads(data)
        else:
            return json.decode(data)