From 07841b42828dc133ba258cf7c7f09d6f8906a96f Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@nttdata.co.jp>
Date: Fri, 18 Apr 2014 11:43:44 +0900
Subject: [PATCH] Fix error log of proxy-server when cache middleware is
 disabled

Change-Id: I0b67721cbb692fb8d2a5dd8b2c4f5383512b7b45
Closes-Bug: #1306591
---
 swift/common/utils.py | 8 ++++----
 swift/proxy/server.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/swift/common/utils.py b/swift/common/utils.py
index 5d2306c8a2..02ef18464b 100644
--- a/swift/common/utils.py
+++ b/swift/common/utils.py
@@ -1535,7 +1535,7 @@ def unlink_older_than(path, mtime):
             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
 
@@ -1545,12 +1545,12 @@ def item_from_env(env, item_name):
     :returns: the value from the environment
     """
     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)
     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
     previously set by the memcache middleware
@@ -1559,7 +1559,7 @@ def cache_from_env(env):
 
     :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):
diff --git a/swift/proxy/server.py b/swift/proxy/server.py
index afa7916329..cfaa78db56 100644
--- a/swift/proxy/server.py
+++ b/swift/proxy/server.py
@@ -255,7 +255,7 @@ class Application(object):
         """
         try:
             if self.memcache is None:
-                self.memcache = cache_from_env(env)
+                self.memcache = cache_from_env(env, True)
             req = self.update_request(Request(env))
             return self.handle_request(req)(env, start_response)
         except UnicodeError: