Merge "Fix error log of proxy-server when cache middleware is disabled"

This commit is contained in:
Jenkins 2014-04-25 10:43:28 +00:00 committed by Gerrit Code Review
commit 6174ea470d
2 changed files with 5 additions and 5 deletions

View File

@ -1535,7 +1535,7 @@ def unlink_older_than(path, mtime):
pass pass
def item_from_env(env, item_name): def item_from_env(env, item_name, allow_none=False):
""" """
Get a value from the wsgi environment Get a value from the wsgi environment
@ -1545,12 +1545,12 @@ def item_from_env(env, item_name):
:returns: the value from the environment :returns: the value from the environment
""" """
item = env.get(item_name, None) item = env.get(item_name, None)
if item is None: if item is None and not allow_none:
logging.error("ERROR: %s could not be found in env!" % item_name) logging.error("ERROR: %s could not be found in env!" % item_name)
return item return item
def cache_from_env(env): def cache_from_env(env, allow_none=False):
""" """
Get memcache connection pool from the environment (which had been Get memcache connection pool from the environment (which had been
previously set by the memcache middleware previously set by the memcache middleware
@ -1559,7 +1559,7 @@ def cache_from_env(env):
:returns: swift.common.memcached.MemcacheRing from environment :returns: swift.common.memcached.MemcacheRing from environment
""" """
return item_from_env(env, 'swift.cache') return item_from_env(env, 'swift.cache', allow_none)
def read_conf_dir(parser, conf_dir): def read_conf_dir(parser, conf_dir):

View File

@ -256,7 +256,7 @@ class Application(object):
""" """
try: try:
if self.memcache is None: if self.memcache is None:
self.memcache = cache_from_env(env) self.memcache = cache_from_env(env, True)
req = self.update_request(Request(env)) req = self.update_request(Request(env))
return self.handle_request(req)(env, start_response) return self.handle_request(req)(env, start_response)
except UnicodeError: except UnicodeError: