Example #1
0
class _Range(JsonRpcDispatcher):
    #    @ndb.toplevel
    #    def get(self):
    #        path_info = self.request.path_info.split("/")
    #        start = int(path_info[3])
    #        end = int(path_info[4])
    #        q = RawData.queryPeriod(start, end)
    #
    #        for raw_data_key in q.fetch(keys_only=True):
    #            self.response.out.write(str(raw_data_key.get()))

    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        try:
            start = int(jrequest.getPathInfo(3))
            end = int(jrequest.getPathInfo(4))
        except Exception, e:
            jresponse.setErrorInvalidParameter(e)
            return

        for key in RawData.fetchRange(start, end):
            raw_data = key.get()
            assert isinstance(raw_data, RawData)
            jresponse.addResult(raw_data)
        jresponse.setColumns(RawDataColumns())
Example #2
0
    def GET(self, json_rpc_request, jresponse):
        assert isinstance(json_rpc_request, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        #start = json_rpc_request.getValue("start")
        #end = json_rpc_request.getValue("end")
        try:
            limit = int(json_rpc_request.getValue("limit")[0])
        except:
            limit = 100

        #json_rpc_response = JsonRpcResponse(json_rpc_request.getId())
        #jresponse.setFieldNames(RawDataColumns().getColumnIds())
        jresponse.setColumns(RawDataColumns())

        q = RawData.queryRecent()
        for key in q.fetch(keys_only=True, limit=limit):
            entity = key.get()
            if not isinstance(entity, RawData): continue
            json_dict = entity.to_dict()
            if not isinstance(json_dict, dict): continue
            jresponse.addResult(json_dict)
Example #3
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()

        client = memcache.Client()
        keys = client.get(self.MEMCACHE_KEY)
        if keys:
            jresponse.setExtraValue("memcache", "hit")
        else:
            jresponse.setExtraValue("memcache", "missed and reloaded")
            keys = RawData.fetchRecent()
            client.set(self.MEMCACHE_KEY, keys, time=70)

        for key in keys:
            raw_data = key.get()
            assert isinstance(raw_data, RawData)
            jresponse.addResult(raw_data)
        jresponse.setColumns(RawDataColumns())

        jresponse.setExtraValue("__name__", __name__)
        jresponse.setExtraValue("__package__", __package__)
        jresponse.setExtraValue("__file__", __file__)
Example #4
0
    def GET(self, json_rpc_request, jresponse):
        assert isinstance(json_rpc_request, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        #start = json_rpc_request.getValue("start")
        #end = json_rpc_request.getValue("end")
        try:
            limit = int(json_rpc_request.getValue("limit")[0])
        except:
            limit = 100

        #json_rpc_response = JsonRpcResponse(json_rpc_request.getId())
        #jresponse.setFieldNames(RawDataColumns().getColumnIds())
        jresponse.setColumns(RawDataColumns())

        q = RawData.queryRecent()
        for key in q.fetch(keys_only=True, limit=limit):
            entity = key.get()
            if not isinstance(entity, RawData): continue
            json_dict = entity.to_dict()
            if not isinstance(json_dict, dict): continue
            jresponse.addResult(json_dict)
Example #5
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()

        client = memcache.Client()
        keys = client.get(self.MEMCACHE_KEY)
        if keys:
            jresponse.setExtraValue("memcache", "hit")
        else:
            jresponse.setExtraValue("memcache", "missed and reloaded")
            keys = RawData.fetchRecent()
            client.set(self.MEMCACHE_KEY, keys, time=70)

        for key in keys:
            raw_data = key.get()
            assert isinstance(raw_data, RawData)
            jresponse.addResult(raw_data)
        jresponse.setColumns(RawDataColumns())

        jresponse.setExtraValue("__name__", __name__)
        jresponse.setExtraValue("__package__", __package__)
        jresponse.setExtraValue("__file__", __file__)