Anonymous committed 5735098

clean up some more

Comments (0)

Files changed (3)

     region = make_region(
+        function_key_generator = my_key_generator
+    ).configure(
-        },
-        function_key_generator = my_key_generator
+        }


 from dogpile import Dogpile, NeedRegenerationException
-from dogpile.cache.util import function_key_generator, PluginLoader
+from dogpile.cache.util import function_key_generator, PluginLoader, memoized_property
 from dogpile.cache.api import NO_VALUE, CachedValue
 import time
          backend.  Is typically a dict.
+        if "backend" in self.__dict__:
+            raise Exception(
+                    "This region is already "
+                    "configured with the %s backend" 
+                    % self.backend)
         backend_cls = _backend_loader.load(backend)
         if _config_argument_dict:
             self.backend = backend_cls.from_config_dict(
             _config_prefix="%s.arguments" % prefix
+    @memoized_property
+    def backend(self):
+        raise Exception("No backend is configured on this region.")
     def get(self, key):
         """Return a value from the cache, based on the given key.


             return mangler(key)
             return key
-    return mangle
+    return mangle
+class memoized_property(object):
+    """A read-only @property that is only evaluated once."""
+    def __init__(self, fget, doc=None):
+        self.fget = fget
+        self.__doc__ = doc or fget.__doc__
+        self.__name__ = fget.__name__
+    def __get__(self, obj, cls):
+        if obj is None:
+            return self
+        obj.__dict__[self.__name__] = result = self.fget(obj)
+        return result
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
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.