Dmitri
Dmitri

Reputation: 121

Disable cache in Pylons app under development mode

I'm using @beaker_cache() decorator in my Pylons application. How can I disable the cache under development mode?

Upvotes: 0

Views: 301

Answers (1)

Pēteris Caune
Pēteris Caune

Reputation: 45092

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

Upvotes: 1

Related Questions