def save_iopub_message(self, topics, msg):
<EOL>try:<EOL><INDENT>msg = self.session.unserialize(msg, content=True)<EOL><DEDENT>except Exception:<EOL><INDENT>self.log.error("<STR_LIT>", exc_info=True)<EOL>return<EOL><DEDENT>parent = msg['<STR_LIT>']<EOL>if not parent:<EOL><INDENT>self.log.warn("<STR_LIT>", msg)<EOL>return<EOL><DEDENT>msg_id = parent['<STR_LIT>']<EOL>msg_type = msg['<STR_LIT>']['<STR_LIT>']<EOL>content = msg['<STR_LIT:content>']<EOL>try:<EOL><INDENT>rec = self.db.get_record(msg_id)<EOL><DEDENT>except KeyError:<EOL><INDENT>rec = empty_record()<EOL>rec['<STR_LIT>'] = msg_id<EOL>self.db.add_record(msg_id, rec)<EOL><DEDENT>d = {}<EOL>if msg_type == '<STR_LIT>':<EOL><INDENT>name = content['<STR_LIT:name>']<EOL>s = rec[name] or '<STR_LIT>'<EOL>d[name] = s + content['<STR_LIT:data>']<EOL><DEDENT>elif msg_type == '<STR_LIT>':<EOL><INDENT>d['<STR_LIT>'] = content<EOL><DEDENT>elif msg_type == '<STR_LIT>':<EOL><INDENT>d['<STR_LIT>'] = content['<STR_LIT:code>']<EOL><DEDENT>elif msg_type in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>d[msg_type] = content<EOL><DEDENT>elif msg_type == '<STR_LIT:status>':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>self.log.warn("<STR_LIT>", msg_type)<EOL><DEDENT>if not d:<EOL><INDENT>return<EOL><DEDENT>try:<EOL><INDENT>self.db.update_record(msg_id, d)<EOL><DEDENT>except Exception:<EOL><INDENT>self.log.error("<STR_LIT>", msg_id, exc_info=True)<EOL><DEDENT>
save an iopub message into the db