Mike Bayer avatar Mike Bayer committed f13a92a

- [bug] Fixed the mako_cache plugin which was not yet
covered, and wasn't implementing the mako plugin
API correctly; fixed docs as well. Courtesy
Ben Hayden.

Comments (0)

Files changed (4)

+0.3.1
+=====
+- [bug] Fixed the mako_cache plugin which was not yet
+  covered, and wasn't implementing the mako plugin
+  API correctly; fixed docs as well.  Courtesy
+  Ben Hayden.
+
 0.3.0
 =====
-- [feature] get() method now checks expiration time 
+- [feature] get() method now checks expiration time
   by default.   Use ignore_expiration=True
   to bypass this.
 
   values must be created after.  Is honored by the
   get_or_create() and get() methods. #7
 
-- [bug] Fixed bug whereby region.get() didn't 
+- [bug] Fixed bug whereby region.get() didn't
   work if the value wasn't present.  #8
 
 0.2.4
   #4
 
 - Added support to DBM file lock to allow reentrant
-  access per key within a single thread, so that 
+  access per key within a single thread, so that
   even though the DBM backend locks for the whole file,
   a creation function that calls upon a different
   key in the cache can still proceed.  #5
 
-- Fixed DBM glitch where multiple readers 
+- Fixed DBM glitch where multiple readers
   could be serialized.
 
 - Adjust bmemcached backend to work with newly-repaired
-  bmemcached calling API (see bmemcached 
+  bmemcached calling API (see bmemcached
   ef206ed4473fec3b639e).
 
 0.2.2

dogpile/cache/__init__.py

-__version__ = '0.3.0'
+__version__ = '0.3.1'
 
 from .region import CacheRegion, register_backend, make_region
Add a comment to this file

tests/cache/plugins/__init__.py

Empty file added.

tests/cache/plugins/test_mako_cache.py

+from .. import eq_
+from unittest import TestCase
+from nose import SkipTest
+
+try:
+    import mako
+except ImportError:
+    raise SkipTest("this test suite requires mako templates")
+
+from mako.template import Template
+from dogpile.cache import make_region
+from mako.cache import register_plugin
+
+register_plugin("dogpile.cache", "dogpile.cache.plugins.mako_cache", "MakoPlugin")
+
+class TestMakoPlugin(TestCase):
+    def _memory_fixture(self):
+        my_regions = {
+            "myregion": make_region().configure(
+                        "dogpile.cache.memory",
+                    ),
+        }
+        return {
+            'cache_impl': 'dogpile.cache',
+            'cache_args': {'regions': my_regions}
+        }
+    def test_basic(self):
+        x = [0]
+        def nextx():
+            x[0] += 1
+            return x[0]
+
+        kw = self._memory_fixture()
+        t = Template(
+            '<%page cached="True" cache_region="myregion"/>${nextx()}',
+            **kw
+        )
+
+        eq_(t.render(nextx=nextx), "1")
+        eq_(t.render(nextx=nextx), "1")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.