示例#1
0
class _ByDataKey(JsonRpcDispatcher):
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        try:
            data_key = ndb.Key("Data", int(jrequest.getPathInfo(4)))
        except Exception, e:
            jresponse.setErrorInvalidParameter(e)
            return
        metadata_keys = MetadataNdb.fetchByData(data_key)
        for metadata_key in metadata_keys:
            jresponse.addResult(metadata_key.get())
示例#2
0
class _ByDataId(JsonRpcDispatcher):
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        try:
            data_id = int(jrequest.getPathInfo(4))
            data_key = DataNdb.getByDataId(data_id)
            if data_key is None: raise RuntimeError("Data entity with dataId %s was not found" % data_id)
            assert isinstance(data_key, ndb.Key)
        except Exception, e:
            jresponse.setErrorInvalidParameter(e)
            return
        assert isinstance(data_key, ndb.Key)
        metadata_keys = MetadataNdb.fetchByData(data_key)
        for metadata_key in metadata_keys:
            jresponse.addResult(metadata_key.get())