コード例 #1
0
def handle_get(conversation):
    fresh = conversation.query['fresh'] == 'true'

    max_timestamp = None
    board_list = []
    session = get_session(application, fresh)
    try:
        try:
            boards = session.query(Board).all()
            for board in boards:
                board_list.append(board.id)
                timestamp = board.timestamp
                if max_timestamp is None or timestamp > max_timestamp:
                    max_timestamp = timestamp
        except NoResultFound:
            return None

        note_list = []
        try:
            notes = session.query(Note).all()
            for note in notes:
                note_list.append(note.to_dict())
        except NoResultFound:
            pass
    finally:
        session.close()

    if max_timestamp is not None:
        conversation.modificationTimestamp = datetime_to_milliseconds(
            max_timestamp)
    return json.write({'boards': board_list, 'notes': note_list})
コード例 #2
0
def handle_get_info(conversation):
    session = get_session(application)
    try:
        max_timestamp = session.query(func.max(Board.timestamp)).scalar()
    finally:
        session.close()
    return datetime_to_milliseconds(max_timestamp)
コード例 #3
0
ファイル: default.py プロジェクト: alanpaulin/prudence
def handle_get_info(conversation):
    session = get_session(application)
    try:
        max_timestamp = session.query(func.max(Board.timestamp)).scalar()
    finally:
        session.close()
    return datetime_to_milliseconds(max_timestamp)
コード例 #4
0
ファイル: default.py プロジェクト: alanpaulin/prudence
def handle_get(conversation):
    fresh = conversation.query['fresh'] == 'true'

    max_timestamp = None
    board_list = []
    session = get_session(application, fresh)
    try:
        try:
            boards = session.query(Board).all()
            for board in boards:
                board_list.append(board.id)
                timestamp = board.timestamp
                if max_timestamp is None or timestamp > max_timestamp:
                    max_timestamp = timestamp
        except NoResultFound:
            return None
    
        note_list = []
        try:
            notes = session.query(Note).all()
            for note in notes:
                note_list.append(note.to_dict())
        except NoResultFound:
            pass
    finally:
        session.close()

    if max_timestamp is not None:
        conversation.modificationTimestamp = datetime_to_milliseconds(max_timestamp)
    return json.write({'boards': board_list, 'notes': note_list})
コード例 #5
0
def handle_get_info2(conversation):
    id = get_id(conversation)

    session = get_session(application)
    try:
        note = session.query(Note).filter_by(id=id).one()
    except NoResultFound:
        return None
    finally:
        session.close()

    return datetime_to_milliseconds(note.timestamp)
コード例 #6
0
ファイル: note.py プロジェクト: alanpaulin/prudence
def handle_get_info2(conversation):
    id = get_id(conversation)

    session = get_session(application)
    try:
        note = session.query(Note).filter_by(id=id).one()
    except NoResultFound:
        return None
    finally:
        session.close()

    return datetime_to_milliseconds(note.timestamp)
コード例 #7
0
ファイル: note.py プロジェクト: alanpaulin/prudence
def handle_get(conversation):
    id = get_id(conversation)

    session = get_session(application)
    try:
        note = session.query(Note).filter_by(id=id).one()
    except NoResultFound:
        return 404
    finally:
        session.close()

    conversation.modificationTimestamp = datetime_to_milliseconds(note.timestamp)
    return json.write(note.to_dict())
コード例 #8
0
def handle_get(conversation):
    id = get_id(conversation)

    session = get_session(application)
    try:
        note = session.query(Note).filter_by(id=id).one()
    except NoResultFound:
        return 404
    finally:
        session.close()

    conversation.modificationTimestamp = datetime_to_milliseconds(
        note.timestamp)
    return json.write(note.to_dict())
コード例 #9
0
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
コード例 #10
0
ファイル: note.py プロジェクト: alanpaulin/prudence
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
コード例 #11
0
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)
コード例 #12
0
ファイル: default.py プロジェクト: alanpaulin/prudence
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)
コード例 #13
0
ファイル: note.py プロジェクト: alanpaulin/prudence
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())
コード例 #14
0
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())