def _get_configdb_data(self, resource):
''' Gets all the data from configdb (the sites structure with everything in it)
:return: list of dictionaries of site data
'''
data = caches['locmem'].get(resource)
if not data:
try:
r = requests.get(settings.CONFIGDB_URL + '/{}/'.format(resource))
r.raise_for_status()
except (requests.exceptions.RequestException, requests.exceptions.HTTPError) as e:
msg = "{}: {}".format(e.__class__.__name__, CONFIGDB_ERROR_MSG)
raise ConfigDBException(msg)
try:
data = r.json()['results']
except KeyError:
raise ConfigDBException(CONFIGDB_ERROR_MSG)
# cache the results for 15 minutes
caches['locmem'].set(resource, data, 900)
return data
评论列表
文章目录