def update(self, msg): try: # insert new room-user record cr = ChatRoom_DB() cr.roomname = msg['roomname'] cr.username = msg['postedby'] cr.datelastposted = msg['dateposted'] cr.save() except Exception, e: #print "Error creating new chatroom-user record", e # if record exists, update time instead try: cr = ChatRoom_DB.objects.get(roomname=msg['roomname'], username=msg['postedby']) cr.datelastposted = msg['dateposted'] cr.save() except Exception, e: print "Error updating chat room", e raise