Commit 8b0f1a03 by Victor Shnayder

get rid of caching--unneeded complexity.

parent 671f2af3
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment