Using beaker cache with pyramid

2010-12-11 Thread Massimiliano Torromeo
Hi, I'm building a new website using pyramid for the first time. I have some experience with pylons and I'm finding some utilities I was using with pylons are missing in pyramid. Up till now I was able to reimplement most of what I needed, but I'm having trouble understanding what is the right way

Re: Using beaker cache with pyramid

2010-12-11 Thread Wichert Akkerman
On 2010-12-11 16:10, Massimiliano Torromeo wrote: I am already using the pyramid_beaker session factory, but there doesn't seem to exist a beaker cache factory (or a valid alternative). No factory is needed. Here is my recipe: from beaker.util import parse_cache_config_options import beake

Re: Using beaker cache with pyramid

2010-12-11 Thread Massimiliano Torromeo
I don't have a run.py. Should I put it in the main function in __init__.py? I tried my idea anyway, even if it didn't seem the correct way to do it (I learned something at least), and it works: # pyramid_beaker_cache/__init__.py from beaker.cache import CacheManager from beaker.util import parse_

Re: Using beaker cache with pyramid

2010-12-11 Thread Daniel Holth
Massimiliano, I went down the same path of looking for a per-request caching middleware that worked in the same way as the session middleware. Eventually I decided caching was not tied to a single request in the same way as a session, so I have a global cache as Wichert suggests. Daniel -- You

Re: Using beaker cache with pyramid

2010-12-11 Thread Jerry
Hi, I tried the Wichert's configuration and declared my view -- @cache.cache_region('long_term') def home_view(request): but got an error -- File '/home/virtualenv/lib/python2.6/site-packages/Beaker-1.5.4- py2.6.egg/beaker/cache.py', line 114 in cached return cache[0].get_value(cache_key, cre

Re: Using beaker cache with pyramid

2010-12-12 Thread Daniel Holth
Pyramid calls a view with the request if it accepts one positional argument, but the cache decorator hides the function's signature so Pyramid passes the context and the request. If you change your view to def home_view(context, request): pass It will probably do something. However, str(context)

Re: Using beaker cache with pyramid

2010-12-12 Thread Jerry
Thanks for the tip. However, the ultimate goal is to cache the template output (e.g., I choose Genshi for its power at some expense of speed) and I'm sure many people would want to know how to juggle Pyramid/Beaker/XTemplate to make it work. Jerry On Dec 13, 3:45 am, Daniel Holth wrote: > Pyram