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_cache_config_options from pyramid.request import Request def BeakerCacheRequestFactory(**options): class BeakerCacheRequest(Request): _cache_options = options _cache = None @property def cache(self): if self._cache is None: self._cache = CacheManager(**self._cache_options) return self._cache return BeakerCacheRequest def request_factory_from_settings(settings): """ Return a Pyramid request using Beaker cache settings supplied from a Paste configuration file""" options = parse_cache_config_options(settings) return BeakerCacheRequestFactory(**options) # application/__init__.py # [...] config = Configurator(settings=settings) request_factory = request_factory_from_settings(settings) config.set_request_factory(request_factory) # [...] And then I use the cache.region decorator: @self.request.cache.region('short_term', 'something') It works, but I will try your method next. Thanks. On Sat, Dec 11, 2010 at 7:14 PM, Wichert Akkerman <wich...@wiggy.net> wrote: > 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 beaker.cache > > settings=config.registry.settings > cfg=parse_cache_config_options(settings) > beaker.cache.cache_regions.update(cfg["cache_regions"]) > > > after putting that in your startup code in run.py you can use the beaker > cache_regions decorator for normal caching. > > Wichert. > > -- > Wichert Akkerman <wich...@wiggy.net> It is simple to make things. > http://www.wiggy.net/ It is hard to make things simple. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-devel" group. > To post to this group, send email to pylons-de...@googlegroups.com. > To unsubscribe from this group, send email to > pylons-devel+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/pylons-devel?hl=en. > > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.