Пример #1
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)
        type = pkt.data['catalog_name']
        n = NetworkPacket()

        if type in self.CATALOGS.keys():
            func = pkt.data['func']
            message = pkt.data['message']
            if func in self.FUNCS:
                if func == 'get_catalog':
                    offset = message['offset']
                    limit = message['limit']

                    n.data['status'] = 'OK'
                    n.data['message'] = toJson(self.CATALOGS[type], offset,
                                               limit)
            else:
                ApiWorker.send_error(ch, method, props, body,
                                     'Invalid func field')
                self.db.close()
        else:
            ApiWorker.send_error(ch, method, props, body,
                                 'Invalid catalog name')
            self.db.close()
            return
        ApiWorker.send_reply(ch, method, props, n.toJson())
        self.db.close()
        return
Пример #2
0
    def on_request(self, ch, method, props, body):
     pkt = NetworkPacket.fromJson(body)
     type = pkt.data['catalog_name']
     n = NetworkPacket()

     if type in self.CATALOGS.keys():
        func = pkt.data['func']
        message = pkt.data['message']
        if func in self.FUNCS:
            if func == 'get_catalog':
                offset = message['offset']
                limit = message['limit']
 
                n.data['status'] = 'OK'
                n.data['message'] = toJson(self.CATALOGS[type], offset, limit)
        else:
            ApiWorker.send_error(ch, method, props, body, 'Invalid func field')
            self.db.close()
     else:
        ApiWorker.send_error(ch, method, props, body, 'Invalid catalog name')
        self.db.close()
        return
     ApiWorker.send_reply(ch, method, props, n.toJson())
     self.db.close()
     return
Пример #3
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)

        uuid = pkt.data['uuid']
        cli_utc = pkt.data['message']['timestamp']

        try:
            user = User.select().where(User.uuid == uuid).get()
        except DoesNotExist, e:
            ApiWorker.send_error(ch, method, props, "User does not Exist")
            return
Пример #4
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)

        uuid = pkt.data['uuid']
        cli_utc = pkt.data['message']['timestamp']

        try:
            user = User.select().where(User.uuid == uuid).get()
        except DoesNotExist, e:
            ApiWorker.send_error(ch, method, props, "User does not Exist")
            return
Пример #5
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)

        uuid = pkt.data['uuid']
        type = pkt.data['func']

        # check if uuid valid
        try:
            user = User.select().where(User.uuid == uuid).get()
        except DoesNotExist, e:
            ApiWorker.send_error(ch, method, props, "User does not Exist")
            return
Пример #6
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)
        type = pkt.data['func']

        #check for valid request
        if type in VALID_REQUEST_TYPES:
            if type in ['login', 'register']:
                self.handle_login(ch, method, props, pkt)
            if type == 'add_account':
                self.handle_addaccount(ch, method, props, pkt)
        else:
            ApiWorker.send_error(ch, method, props, 'Invalid request field type')
Пример #7
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)

        uuid = pkt.data['uuid']
        type = pkt.data['func']

        # check if uuid valid
        try:
            user = User.select().where(User.uuid == uuid).get()
        except DoesNotExist, e:
            ApiWorker.send_error(ch, method, props, "User does not Exist")
            return
Пример #8
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)
        type = pkt.data['func']

        #check for valid request
        if type in VALID_REQUEST_TYPES:
            if type in ['login', 'register']:
                self.handle_login(ch, method, props, pkt)
            if type == 'add_account':
                self.handle_addaccount(ch, method, props, pkt)
        else:
            ApiWorker.send_error(ch, method, props,
                                 'Invalid request field type')