MissingCacheParameter
My full traceback
URL: http://127.0.0.1:5001/
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/WebError-0.10.1-py2.5.egg/weberror/evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File '/usr/lib/python2.5/site-packages/ToscaWidgets-0.9.3-py2.5.egg/tw/core/middleware.py', line 36 in __call__
return self.wsgi_app(environ, start_response)
File '/usr/lib/python2.5/site-packages/ToscaWidgets-0.9.3-py2.5.egg/tw/core/middleware.py', line 59 in wsgi_app
resp = req.get_response(self.application)
File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1325 in get_response
File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1293 in call_application
File '/usr/lib/python2.5/site-packages/ToscaWidgets-0.9.3-py2.5.egg/tw/core/resource_injector.py', line 67 in _injector
resp = req.get_response(app)
File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1325 in get_response
File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1293 in call_application
File '/usr/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/gzipper.py', line 38 in __call__
response.gzip_start_response)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Beaker-1.3.1-py2.5.egg/beaker/middleware.py', line 70 in __call__
return self.app(environ, start_response)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Beaker-1.3.1-py2.5.egg/beaker/middleware.py', line 149 in __call__
return self.wrap_app(environ, session_start_response)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/__init__.py', line 324 in __call__
return self.app(environ, start_response)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/cookie.py', line 396 in __call__
return self.app(environ, cookie_setting_start_response)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/open_id.py', line 476 in __call__
return self.app(environ, start_response)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/open_id.py', line 230 in __call__
return self.app(environ, start_response)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/multi.py', line 85 in __call__
app_iter = app(environ, start_response)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/multi.py', line 55 in app
return self.default(environ, find)
File '/usr/lib/python2.5/site-packages/AuthKit-0.4.2-py2.5.egg/authkit/authenticate/__init__.py', line 314 in __call__
return self.app(environ, start_response)
File '/usr/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpexceptions.py', line 636 in __call__
return self.application(environ, start_response)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Routes-1.10.3-py2.5.egg/routes/middleware.py', line 130 in __call__
response = self.app(environ, start_response)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/wsgiapp.py', line 125 in __call__
response = self.dispatch(controller, environ, start_response)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/wsgiapp.py', line 324 in dispatch
return controller(environ, start_response)
File '/home/walter/devel/pylons/artigos/artigos/lib/base.py', line 28 in __call__
return WSGIController.__call__(self, environ, start_response)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 221 in __call__
response = self._dispatch_call()
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 172 in _dispatch_call
response = self._inspect_call(func)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 107 in _inspect_call
result = self._perform_call(func, args)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py', line 60 in _perform_call
return func(**args)
File '<string>', line 2 in view
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/decorators/cache.py', line 97 in wrapper
my_cache = pylons.cache.get_cache(namespace, **b_kwargs)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Beaker-1.3.1-py2.5.egg/beaker/cache.py', line 187 in get_cache
return self.caches.setdefault(name + str(kw), Cache(name, **kw))
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Beaker-1.3.1-py2.5.egg/beaker/cache.py', line 104 in __init__
self.namespace = cls(namespace, **nsargs)
File '/home/walter/.virtualenvs/pylons/lib/python2.5/site-packages/Beaker-1.3.1-py2.5.egg/beaker/container.py', line 485 in __init__
raise MissingCacheParameter("data_dir or file_dir is required")
MissingCacheParameter: data_dir or file_dir is required
Can someone help me?
This is the same error I reported yesterday, but I haven't seen any
diagnosis yet. I'll have to disable @beaker_cache in the meantime.
--
Mike Orr <slugg...@gmail.com>
But I /did/ manage to get @cache.cache to work by supplying a
data_dir:
@cache.cache('foobar2', type='file',
data_dir='./data/cache',
expire=3600)
> But I /did/ manage to get @cache.cache to work by supplying a
> data_dir:
>
> @cache.cache('foobar2', type='file',
> data_dir='./data/cache',
> expire=3600)
>
> Yes, looks like the problem is that the data_dir setting from teh
> ini file is being ignored.. is possible to use
> datadir=pylons.config.whateverthatidontremember['data_dir'] but this
> is not clean ;)
I can't seem to reproduce this. It works fine here.
Can you indicate where you got 'cache' from? And what method you're
decorating?
Here's the recommend method for using the Beaker cache object.
1) Turn off the CacheMiddleware in your config/middleware.py
2) In your lib/app_globals.py add the following imports:
from pylons import config
from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
3) In lib/app_globals.py, add the following to the Globals __init__
method:
self.cache = CacheManager(**parse_cache_config_options(config))
4) In the controller action of your choice, find something that takes
a long time to generate, and decorate with the cache method, for
example in one of my own projects:
from pylons import app_globals
def load_cases(tag):
@app_globals.cache.region('short_term')
def fetch_cases(tag):
# Collect recent stats of interest
# Show recently filed cases
....
return (recent_cases, trials)
return fetch_cases(tag)
Note that merely importing the module will not cause the decorator to
run. This is a *very important* distinction between having the use of
the decorator on a nested function, than one that will be immediately
evaluated on import. When using the cache.cache or cache.region
decorator inside a Pylons controller method, you should also nest it
around the expensive bit as the example above, to prevent premature
execution of the decorator function (ie, running it when the
app_globals isn't actually setup).
This could be affecting the use causing the problem, if you're using
the pylons.cache reference, because it might not actually be fully
setup yet (thus missing the data_dir option). If you're directly
decorating a controller method, move it to a nested function.
The way I recommend here will also be default going forward in Pylons
as it avoids the unnecessary constant CacheMiddleware execution step,
when the cache object should be always available anyways in the app.
Cheers,
Ben