def Post(request): #StatementPostRequest
        data = request.data
        header = request.header

        statements = [Statement(header.arm, counter.id, floorer.id, counter.date, counter.state, counter.value, counter.channel) \
                        for floorer in data.floorers \
                            for counter in floorer.counters]

        Session.open()
        map(lambda statement: statement.save(), statements)
        Session.close()

        request.header.update_date()
        request.header.update_id()

        internal_request = CloseSessionRequest()
        response = StatementPostResponse(header = request.header, request = internal_request)

        return response
Beispiel #2
0
def setup_db():
    Session.open()

    Statement.create_table(fail_silently=True)

    Session.close()