]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Added a way to disable memcache error ignoring and documented the change. Also chang...
authorArmin Ronacher <armin.ronacher@active-4.com>
Sun, 19 May 2013 10:06:18 +0000 (11:06 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sun, 19 May 2013 10:06:18 +0000 (11:06 +0100)
CHANGES
jinja2/bccache.py

diff --git a/CHANGES b/CHANGES
index e4aa398c149ab018e968ab250e95a89a0aa03e8e..b7f28dde50ad9243902fb2f0e6fd8526841fc676 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,7 @@ Version 2.7
 - Allow `contextfunction` and other decorators to be applied to `__call__`.
 - Added support for changing from newline to different signs in the `wordwrap`
   filter.
+- Added support for ignoring memcache errors silently.
 
 Version 2.6
 -----------
index 033ae7a235c963fd15d26779cc73a6b1fd004311..f02291801e91c2263121b855b6d033a916c2e397 100644 (file)
@@ -281,17 +281,25 @@ class MemcachedBytecodeCache(BytecodeCache):
 
     This bytecode cache does not support clearing of used items in the cache.
     The clear method is a no-operation function.
+
+    .. versionadded:: 2.7
+       Added support for ignoring memcache errors through the
+       `ignore_memcache_errors` parameter.
     """
 
-    def __init__(self, client, prefix='jinja2/bytecode/', timeout=None):
+    def __init__(self, client, prefix='jinja2/bytecode/', timeout=None,
+                 ignore_memcache_errors=True):
         self.client = client
         self.prefix = prefix
         self.timeout = timeout
+        self.ignore_memcache_errors = ignore_memcache_errors
 
     def load_bytecode(self, bucket):
         try:
             code = self.client.get(self.prefix + bucket.key)
-        except:
+        except Exception:
+            if not self.ignore_memcache_errors:
+                raise
             code = None
         if code is not None:
             bucket.bytecode_from_string(code)
@@ -302,5 +310,6 @@ class MemcachedBytecodeCache(BytecodeCache):
             args += (self.timeout,)
         try:
             self.client.set(*args)
-        except:
-            pass
+        except Exception:
+            if not self.ignore_memcache_errors:
+                raise