Ticket #12019: cache.py.patch

File cache.py.patch, 1.2 KB (added by rokclimb15, 15 years ago)

Patch for cache decorator function

  • django/views/decorators/cache.py

     
    1616except ImportError:
    1717    from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
    1818
     19from django.conf import settings
    1920from django.utils.decorators import decorator_from_middleware_with_args, available_attrs
    2021from django.utils.cache import patch_cache_control, add_never_cache_headers
    2122from django.middleware.cache import CacheMiddleware
     
    4748        else:
    4849            assert False, "cache_page must be passed either a single argument (timeout) or a view function and a timeout"
    4950    else:
    50         return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[0], key_prefix=key_prefix)
     51        # Handle case of no args passed
     52        try:
     53            cache_timeout = args[0]
     54        except IndexError:
     55            cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
     56        return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=cache_timeout, key_prefix=key_prefix)
    5157
    5258
    5359def cache_control(**kwargs):
Back to Top