#16334: cache_page decorator does not accept "cache" keyword argument
-----------------------+-------------------------------------
 Reporter:  anonymous  |          Owner:  nobody
     Type:  Bug        |         Status:  new
Milestone:             |      Component:  Core (Cache system)
  Version:  1.3        |       Severity:  Normal
 Keywords:             |   Triage Stage:  Unreviewed
Has patch:  0          |  Easy pickings:  0
    UI/UX:  0          |
-----------------------+-------------------------------------
 Docs for cache_page:
 
https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs#django.views.decorators.cache.cache_page

 They point out a `cache` keyword argument one can use:

    cache_page can also take an optional keyword argument, cache, which
 directs the decorator to use a specific cache alias when caching view
 results. By default, the default alias will be used, but you can specify
 any cache alias you want

 I assume this means I can specify the cache_key to use. So, like the docs
 state I try this out:

    @cache_page(60 * 15, cache="special_cache")
    def  my_view(request):
         ....

 As soon as I do this I get a ValueError with the following exception &
 traceback:

 "need more than 1 value to unpack"

 {{{
 Request Method: GET
 Request URL: ...

 Django Version: 1.3
 Python Version: 2.6.1
 Installed Applications:
 ['django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.flatpages',
  'django.contrib.humanize',
  'django.contrib.messages',
  'django.contrib.sessions',
  'django.contrib.sites',
  'django.contrib.markup',
  'django.contrib.comments',
 ...
 ...
 ]


 Traceback:
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/handlers/base.py" in get_response
   101.                             request.path_info)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/urlresolvers.py" in resolve
   252.                     sub_match = pattern.resolve(new_path)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/urlresolvers.py" in resolve
   252.                     sub_match = pattern.resolve(new_path)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/urlresolvers.py" in resolve
   158.             return ResolverMatch(self.callback, args, kwargs,
 self.name)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/urlresolvers.py" in _get_callback
   164.             self._callback = get_callable(self._callback_str)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/utils/functional.py" in wrapper
   124.         result = func(*args)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/urlresolvers.py" in get_callable
   91.                 lookup_view = getattr(import_module(mod_name),
 func_name)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/utils/importlib.py" in import_module
   35.     __import__(name)
 File
 "/Users/bartekc/domains/www.mysite.com/mysite/about_us/careers/views.py"
 in <module>
   23. @cache_page(60 * 60, cache="careers_special")
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/views/decorators/cache.py" in cache_page
   58.             return
 decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[0],
 cache_alias=cache_alias, key_prefix=key_prefix)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/utils/decorators.py" in _make_decorator
   81.         middleware = middleware_class(*m_args, **m_kwargs)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/middleware/cache.py" in __init__
   204.         self.cache = get_cache(self.cache_alias, **cache_kwargs)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/cache/__init__.py" in get_cache
   173.             backend, location, params = parse_backend_conf(backend,
 **kwargs)
 File "/Users/bartekc/.virtualenvs/www.mysite.com/lib/python2.6/site-
 packages/django/core/cache/__init__.py" in parse_backend_conf
   131.         mod_path, cls_name = backend.rsplit('.', 1)

 Exception Type: ValueError at ...
 Exception Value: need more than 1 value to unpack
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16334>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to