def handle_delete(conversation): id = get_id(conversation) session = get_session(application) try: note = session.query(Note).filter_by(id=id).one() session.delete(note) update_board_timestamp(session, note, now()) session.flush() except NoResultFound: return 404 finally: session.close() return None
def handle_put(conversation): # Note: You can only "consume" the entity once, so if we want it # as text, and want to refer to it more than once, we should keep # a reference to that text. text = conversation.entity.text note_dict = json.read(text) note = Note.create_from_dict(note_dict) session = get_session(application) try: session.add(note) update_board_timestamp(session, note) session.flush() finally: session.close() return handle_get(conversation)
def handle_post(conversation): id = get_id(conversation) # Note: You can only "consume" the entity once, so if we want it # as text, and want to refer to it more than once, we should keep # a reference to that text. text = conversation.entity.text note_dict = json.read(text) session = get_session(application) try: note = session.query(Note).filter_by(id=id).one() note.update(note_dict) update_board_timestamp(session, note) session.flush() except NoResultFound: return 404 finally: session.close() conversation.modificationTimestamp = datetime_to_milliseconds(note.timestamp) return json.write(note.to_dict())
def handle_post(conversation): id = get_id(conversation) # Note: You can only "consume" the entity once, so if we want it # as text, and want to refer to it more than once, we should keep # a reference to that text. text = conversation.entity.text note_dict = json.read(text) session = get_session(application) try: note = session.query(Note).filter_by(id=id).one() note.update(note_dict) update_board_timestamp(session, note) session.flush() except NoResultFound: return 404 finally: session.close() conversation.modificationTimestamp = datetime_to_milliseconds( note.timestamp) return json.write(note.to_dict())