get rid of caching--unneeded complexity.
This commit is contained in:
@@ -14,28 +14,16 @@ log = logging.getLogger(__name__)
|
||||
def get_site_status_msg():
|
||||
"""
|
||||
Look for a file settings.STATUS_MESSAGE_PATH. If found, return the
|
||||
contents. Otherwise, return None. Caches result for 10 seconds, per-machine.
|
||||
contents. Otherwise, return None.
|
||||
|
||||
If something goes wrong, returns None. ("is there a status msg?" logic is
|
||||
not allowed to break the entire site).
|
||||
"""
|
||||
cache_time = 10
|
||||
try:
|
||||
key = ','.join([settings.HOSTNAME, settings.STATUS_MESSAGE_PATH])
|
||||
content = cache.get(key)
|
||||
if content == '':
|
||||
# cached that there isn't a status message
|
||||
return None
|
||||
|
||||
if content is None:
|
||||
# nothing in the cache, so check the filesystem
|
||||
if os.path.isfile(settings.STATUS_MESSAGE_PATH):
|
||||
with open(settings.STATUS_MESSAGE_PATH) as f:
|
||||
content = f.read()
|
||||
else:
|
||||
# remember that there isn't anything there
|
||||
cache.set(key, '', cache_time)
|
||||
content = None
|
||||
content = None
|
||||
if os.path.isfile(settings.STATUS_MESSAGE_PATH):
|
||||
with open(settings.STATUS_MESSAGE_PATH) as f:
|
||||
content = f.read()
|
||||
|
||||
return content
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user