Disable cache in Pylons app under development mode
I'm using @beaker_cache()
decorator in my Pylons application.
How can I disable the cach开发者_StackOverflow社区e under development mode?
You could write your own decorator which looks at pylons.config["debug"], and depending on that either returns function unchanged or decorated with beaker_cache. Something along these lines (completely untested!):
from pylons import config
def my_cache(*args, **kwargs):
if config["debug"]:
decorate = lambda f: f
else:
decorate = beaker_cache(*args, **kwargs)
return decorate
精彩评论