Ticket #15840: 15840.patch.2.diff

File 15840.patch.2.diff, 2.4 KB (added by dmclain, 13 years ago)

Sackcloth and ashes tour

  • django/views/decorators/http.py

    diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
    index 6fc882e..482d5ee 100644
    a b def condition(etag_func=None, last_modified_func=None):  
    154154
    155155            return response
    156156
    157         return inner
     157        return wraps(func, assigned=available_attrs(func))(inner)
    158158    return decorator
    159159
    160160# Shortcut decorators for common cases based on ETag or Last-Modified only
  • tests/regressiontests/decorators/tests.py

    diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py
    index 52a1ecd..cfac6de 100644
    a b from django.http import HttpResponse, HttpRequest, HttpResponseNotAllowed  
    66from django.utils.decorators import method_decorator
    77from django.utils.functional import allow_lazy, lazy, memoize
    88from django.utils.unittest import TestCase
    9 from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe
     9from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe, condition, etag, last_modified
    1010from django.views.decorators.vary import vary_on_headers, vary_on_cookie
    1111from django.views.decorators.cache import cache_page, never_cache, cache_control
    1212
    fully_decorated.anything = "Expected __dict__"  
    2020fully_decorated = require_http_methods(["GET"])(fully_decorated)
    2121fully_decorated = require_GET(fully_decorated)
    2222fully_decorated = require_POST(fully_decorated)
     23
     24def last_modified_method(request):
     25    return None
     26
     27def etag_method(request):
     28    return None
     29
     30fully_decorated = condition(etag_func=etag_method, last_modified_func=last_modified_method)(fully_decorated)
     31fully_decorated = etag(etag_method)(fully_decorated)
     32fully_decorated = last_modified(last_modified_method)(fully_decorated)
     33
    2334fully_decorated = require_safe(fully_decorated)
    2435
     36def last_modified_method(request):
     37    return None
     38
     39def etag_method(request):
     40    return None
     41
     42fully_decorated = condition(etag_func=etag_method, last_modified_func=last_modified_method)(fully_decorated)
     43fully_decorated = etag(etag_method)(fully_decorated)
     44fully_decorated = last_modified(last_modified_method)(fully_decorated)
     45
    2546# django.views.decorators.vary
    2647fully_decorated = vary_on_headers('Accept-language')(fully_decorated)
    2748fully_decorated = vary_on_cookie(fully_decorated)
Back to Top