Agreed, I do something similar:
CACHE = {}
def cachepage():
def decorator(func):
def proxyfunc(self, *args, **kw):
url = web.ctx.get('fullpath')
if url not in CACHE:
CACHE[url] = func(self, *args, **kw)
return CACHE[url]
return proxyfunc
return decorator
You can use this to decorate your GET methods. For POST methods, you
can just "del CACHE[web.ctx.fullpath]" or wherever that page may
change.
On Oct 18, 6:39 pm, "Aaron Swartz" <[EMAIL PROTECTED]> wrote:
> Nobody has written code that does just this AFAIK, but it shouldn't be
> too hard. You have a dict-like object that stores the cache, then a
> decorator that works like memoize but deletes the cache entry if
> forceupdate is sent (I'd suggest making it a POST rather than a GET,
> though, so that search engines and so on don't accidentally empty your
> cache).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---