Hi

Thanks in advance

Whats mean:

expensive_func ? and

mycache = cache.get_cache('my_function') ==> my_function ?

I tried in lib/app_globals.py
self.expensive_func = "myDinamicDir" ??? or a link to a new Function?

I read about config and app_globals

"Because the app_globals object is persistent across requests, it can
be modified by any thread. This means it is possible that a value
attached to app_globals might be different at the start of a request
than at the end if another thread has changed its value in between.
... if you aren’t used to working in multithreaded environments"

How I want multithreaded environment Should I use Template Context c Global?

"...The c global is reset on each request so that you don’t need to
worry about a controller still having old values set from a previous
request..."

My target isnt cache itself but store my session where I want. Beaker
control Sessions dir with data_dir too and I need custom to fit my
needs.

So I read 
/usr/lib/python2.6/site-packages/Beaker-1.5.3-py2.6.egg/beaker/container.py

class FileNamespaceManager(OpenResourceNamespaceManager):

So I could just custom this class but my fraid is "multithreaded"
trouble so What Pylons Team recommend?

I know isnt recommend custom a class inside a package but is a easy
solution. I not very familiar with all python concepts. Could someone
recommend if I need apply some Design Partner to resolve this issue?

Best Regards

Mario
macm




2010/4/30 Eryx Lee <[email protected]>:
> 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].
>> > 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.
>>
>
> --
> 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.
>

-- 
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