Issue #2 new

ConfigInjectedRegion, for wsgi/etc. integration

Mike Bayer
repo owner created an issue

{{{

!diff

diff -r 30c1bb640e322dcd86215f38741691d1ed839720 dogpile/cache/region.py --- a/dogpile/cache/region.py Mon Apr 09 11:13:16 2012 -0400 +++ b/dogpile/cache/region.py Mon Apr 09 15:54:02 2012 -0400 @@ -371,3 +371,32 @@ """ return CacheRegion(arg, *kw)

+ +class ConfigInjectedRegion(CacheRegion): + """A :class:.CacheRegion which accepts a runtime method + of determining backend configuration. +
+ Supports ad-hoc backends per call, allowing storage of + backend implementations inside of application specific + registries, such as wsgi environments. +
+ """ + + def region_registry(self): + """Return a dictionary where :class:.ConfigInjectedRegion + will store backend implementations. +
+ This is typically stored in a place like wsgi + environment or other application configuration. +
+ """ + raise NotImplementedError() + + def configure(self, backend, kw): + self.region_registry()[self.name] = super( + ConfigInjectedRegion, self).configure(backend, kw) + + Property + def backend(self): + return self.region_registry()[self.name] +

}}}

Comments (0)

  1. Log in to comment