def email_contents(self): # --- Decode & unpickle the message pickle_input = base64.b64decode(self._email_contents) # In-memory pickle input pi = memfile(pickle_input) message = pickle.load(pi) return message
def email_contents(self, email_message): # --- Pickle & encode the message for storage in a TextField. # In-memory pickle output. po = memfile() pickle.dump(email_message, po) pickle_output = po.getvalue() po.close() self._email_contents = base64.encodestring(pickle_output)