Created
February 23, 2010 12:33
-
-
Save bruntonspall/312131 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cached(name, timeout=60): | |
def wrapper(method): | |
@functools.wraps(method) | |
def wrapper(self, *args, **kwargs): | |
data = memcache.get(name) | |
if not data: | |
logging.info("CACHE MISS for "+name) | |
data = method(self, *args, **kwargs) | |
memcache.set(name, data, timeout) | |
return data | |
return wrapper | |
return wrapper | |
def set_content_type(content_type): | |
def wrapper(method): | |
@functools.wraps(method) | |
def wrapper(self, *args, **kwargs): | |
self.response.headers["Content-Type"] = content_type | |
return method(self, *args, **kwargs) | |
return wrapper | |
return wrapper | |
def write_response(method): | |
@functools.wraps(method) | |
def wrapper(self, *args, **kwargs): | |
self.response.out.write(method(self, *args, **kwargs)) | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment