You can use "CacheManager" to create your own cache in your specified
directory dynamically. But do you actually need to create different caches
in your controllers? Or just using separate cache region by "get_cache" but
save to the same cache directory?

Sample:
from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options

cache_opts = {
    'cache.type': 'file',
    'cache.data_dir': '/tmp/cache/data',
    'cache.lock_dir': '/tmp/cache/lock'
}

cache = CacheManager(**parse_cache_config_options(cache_opts))
mycache = cache.get_cache('my_function')
myvalue = mycache.get_value(key="test", createfunc=expensive_function,
expiretime=60)



On Sat, May 1, 2010 at 3:41 AM, Gael Pasgrimaud <[email protected]> wrote:

> On Fri, Apr 30, 2010 at 9:27 PM, macm <[email protected]> wrote:
> > Hi Folks
> >
> > I am newbie in pylons and python
> >
> > How can I custom my cache_dir dynamically in controller?
> >
> > So I dont want use development.ini
> > cache_dir = %(here)s/data
> >
> > I want add in my controller something like that
> >
> > config['cache_dir'] = MyDynamicallyDir
> >
> > But after read a lot about wsgi and midlleware I see this:
> > config['pylons.app_globals'].mako_lookup = TemplateLookup( ....
> >
> > ... and I still lost!
> >
> > I am using mako and at this moment no sql.
> >
> > So is it possible custom config['cache_dir'] in controller?
> > How can I change config['cache_dir'] in controller?
> > Should I create a mako template base? and <%inherit something ?/>
> >
>
> I guess you need to instantiate your own Cache
> http://beaker.groovie.org/modules/cache.html#beaker.cache.Cache
>
>  self.cache = Cache(**kw)
>
> But maybe you can use cache_region instead
>
> > Regards
> >
> > macm
> > Mario
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<pylons-discuss%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<pylons-discuss%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to