|
|
@ -19,17 +19,20 @@ class UrlTable(object):
|
|
|
|
async def get(self, key, ns=None):
|
|
|
|
async def get(self, key, ns=None):
|
|
|
|
""" Get the given key in the provided namespace
|
|
|
|
""" Get the given key in the provided namespace
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
logging.debug("Table get {}".format(key))
|
|
|
|
if ns is not None:
|
|
|
|
if ns is not None:
|
|
|
|
key += "/" + ns
|
|
|
|
key += "/" + ns
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
async with session.get(self.url_pattern.format(key)) as request:
|
|
|
|
async with session.get(self.url_pattern.format(key)) as request:
|
|
|
|
if request.status == 200:
|
|
|
|
if request.status == 200:
|
|
|
|
result = await request.json()
|
|
|
|
result = await request.json()
|
|
|
|
|
|
|
|
logging.debug("Table get {} is {}".format(key, result))
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
async def set(self, key, value, ns=None):
|
|
|
|
async def set(self, key, value, ns=None):
|
|
|
|
""" Set a value for the given key in the provided namespace
|
|
|
|
""" Set a value for the given key in the provided namespace
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
logging.debug("Table set {} to {}".format(key, value))
|
|
|
|
if ns is not None:
|
|
|
|
if ns is not None:
|
|
|
|
key += "/" + ns
|
|
|
|
key += "/" + ns
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
@ -38,6 +41,7 @@ class UrlTable(object):
|
|
|
|
async def iter(self, cat):
|
|
|
|
async def iter(self, cat):
|
|
|
|
""" Iterate the given key (experimental)
|
|
|
|
""" Iterate the given key (experimental)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
logging.debug("Table iter {}".format(cat))
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
async with session.get(self.url_pattern.format(cat)) as request:
|
|
|
|
async with session.get(self.url_pattern.format(cat)) as request:
|
|
|
|
if request.status == 200:
|
|
|
|
if request.status == 200:
|
|
|
|