tags:

views:

93

answers:

1

Hello!

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

A: 

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
Pēteris Caune